Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: verify incorrect keys in :compare_with_key() #8

Merged
merged 1 commit into from
Dec 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 25 additions & 1 deletion test/tuple_keydef.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ local tuple_keydef_new_cases = {

local test = tap.test('tuple.keydef')

test:plan(#tuple_keydef_new_cases - 1 + 8)
test:plan(#tuple_keydef_new_cases - 1 + 9)
for _, case in ipairs(tuple_keydef_new_cases) do
if type(case) == 'function' then
case()
Expand Down Expand Up @@ -604,4 +604,28 @@ test:test('JSON path is not supported error', function(test)
'verify error message')
end)

-- gh-7: incorrect keys for :compare_with_key().
--
-- See also https://github.com/tarantool/tarantool/issues/5307
test:test('no segfault at incorrect key in :compare_with_key()', function(test)
test:plan(3)

local keydef = tuple_keydef.new({{fieldno = 1, type = 'unsigned'}})

-- Should succeed.
local ok, res = pcall(keydef.compare_with_key, keydef, {1}, {1})
test:ok(ok and res == 0, 'Simple equality')

-- Should succeed.
local ok, res = pcall(keydef.compare_with_key, keydef, {1}, {2})
test:ok(ok and res < 0, 'Simple inequality')

-- Should fail.
local exp_err = 'Invalid key part count (expected [0..1], got 9)'
local ok, res = pcall(keydef.compare_with_key, keydef, {1},
{1, 2, 3, 4, 5, 6, 7, 8, 9})
test:is_deeply({ok, tostring(res)}, {false, exp_err},
'Invalid key part count')
end)

os.exit(test:check() and 0 or 1)