unittests: Add test for tv_dict_set_keys_readonly

This commit is contained in:
ZyX 2017-03-13 19:04:59 +03:00
parent 368a61c525
commit e43de6bb3e

View File

@ -2187,5 +2187,18 @@ describe('typval.c', function()
eq(1, d_copy1.dv_refcount)
end)
end)
describe('set_keys_readonly()', function()
itp('works', function()
local d = dict({a=true})
local dis = dict_items(d)
alloc_log:check({a.dict(d), a.di(dis.a)})
eq(0, bit.band(dis.a.di_flags, lib.DI_FLAGS_RO))
eq(0, bit.band(dis.a.di_flags, lib.DI_FLAGS_FIX))
lib.tv_dict_set_keys_readonly(d)
alloc_log:check({})
eq(lib.DI_FLAGS_RO, bit.band(dis.a.di_flags, lib.DI_FLAGS_RO))
eq(lib.DI_FLAGS_FIX, bit.band(dis.a.di_flags, lib.DI_FLAGS_FIX))
end)
end)
end)
end)