Skip to content
Snippets Groups Projects
Commit 90469d65 authored by Alexandr Lyapunov's avatar Alexandr Lyapunov
Browse files

fixed gh-769 : Added a test for iterator.LT and iterator.GT for non-unique indexes

parent 35daf234
No related branches found
No related tags found
No related merge requests found
-- test for https://github.com/tarantool/tarantool/issues/769
s = box.schema.create_space('test')
---
...
i = s:create_index('primary', { type = 'TREE', parts = {1, 'num', 2, 'num'} })
---
...
s:insert{0, 0} s:insert{2, 0}
---
...
for i=1,100000 do s:insert{1, i} end
---
...
test_itrs = {'EQ', 'REQ', 'GT', 'LT', 'GE', 'LE'}
---
...
test_res = {}
---
...
too_longs = {}
---
...
--# setopt delimiter ';'
function test_run_itr(itr, key)
for i=1,10000 do
local gen, param, state = s.index.primary:pairs({key}, {iterator = itr})
state, v = gen(param, state)
test_res[itr .. ' ' .. key] = v
end
end;
---
...
function test_itr(itr, key)
local t = os.time()
test_run_itr(itr, key)
if os.time() - t > 1 then
table.insert(too_longs, 'Too long ' .. itr .. ' ' .. key)
end
end;
---
...
for _,itr in pairs(test_itrs) do
for key = 0,2 do
test_itr(itr, key)
end
end;
---
...
--# setopt delimiter ''
test_res
---
- LE 1: [1, 100000]
LT 2: [1, 100000]
REQ 1: [1, 100000]
EQ 2: [2, 0]
LE 2: [2, 0]
EQ 0: [0, 0]
LT 1: [0, 0]
GE 0: [0, 0]
REQ 0: [0, 0]
GT 0: [1, 1]
GT 1: [2, 0]
LE 0: [0, 0]
REQ 2: [2, 0]
EQ 1: [1, 1]
GE 1: [1, 1]
GE 2: [2, 0]
...
too_longs
---
- []
...
s:drop()
---
...
test_itr = nil test_run_itr = nil test_itrs = nil s = nil
---
...
'done'
---
- done
...
-- test for https://github.com/tarantool/tarantool/issues/769
s = box.schema.create_space('test')
i = s:create_index('primary', { type = 'TREE', parts = {1, 'num', 2, 'num'} })
s:insert{0, 0} s:insert{2, 0}
for i=1,100000 do s:insert{1, i} end
test_itrs = {'EQ', 'REQ', 'GT', 'LT', 'GE', 'LE'}
test_res = {}
too_longs = {}
--# setopt delimiter ';'
function test_run_itr(itr, key)
for i=1,10000 do
local gen, param, state = s.index.primary:pairs({key}, {iterator = itr})
state, v = gen(param, state)
test_res[itr .. ' ' .. key] = v
end
end;
function test_itr(itr, key)
local t = os.time()
test_run_itr(itr, key)
if os.time() - t > 1 then
table.insert(too_longs, 'Too long ' .. itr .. ' ' .. key)
end
end;
for _,itr in pairs(test_itrs) do
for key = 0,2 do
test_itr(itr, key)
end
end;
--# setopt delimiter ''
test_res
too_longs
s:drop()
test_itr = nil test_run_itr = nil test_itrs = nil s = nil
'done'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment