unittests: Add tv_dict_clear tests

This commit is contained in:
ZyX 2017-03-13 13:43:25 +03:00
parent 43e9fad1c8
commit 4987850cac

View File

@ -1887,5 +1887,23 @@ describe('typval.c', function()
end)
end)
end)
describe('clear()', function()
itp('works', function()
local d = dict()
alloc_log:check({a.dict(d)})
eq({}, dct2tbl(d))
lib.tv_dict_clear(d)
eq({}, dct2tbl(d))
lib.tv_dict_add_str(d, 'TEST', 3, 'tEsT')
local dis = dict_items(d)
local di = dis.TES
local di_s = di.di_tv.vval.v_string
alloc_log:check({a.di(di), a.str(di_s)})
eq({TES='tEsT'}, dct2tbl(d))
lib.tv_dict_clear(d)
alloc_log:check({a.freed(di_s), a.freed(di)})
eq({}, dct2tbl(d))
end)
end)
end)
end)