mirror of
https://github.com/gvx/bitser.git
synced 2024-11-11 01:44:21 +00:00
Change tests again
Would be useful if I could run luaspec locally but oh well
This commit is contained in:
parent
b7cc46f4bf
commit
772f090413
@ -299,22 +299,25 @@ describe("bitser", function()
|
|||||||
bitser.dumpLoveFile("some_file_name", v)
|
bitser.dumpLoveFile("some_file_name", v)
|
||||||
assert.are.same(v, bitser.loadLoveFile("some_file_name"))
|
assert.are.same(v, bitser.loadLoveFile("some_file_name"))
|
||||||
end)
|
end)
|
||||||
it("can read and write cdata", function()
|
it("can read and write simple cdata", function()
|
||||||
-- a simple value
|
|
||||||
test_serdeser(ffi.new('double', 42.5))
|
test_serdeser(ffi.new('double', 42.5))
|
||||||
|
end)
|
||||||
|
before = function ()
|
||||||
ffi.cdef[[
|
ffi.cdef[[
|
||||||
struct some_struct {
|
struct some_struct {
|
||||||
int a;
|
int a;
|
||||||
double b;
|
double b;
|
||||||
};
|
};
|
||||||
]]
|
]]
|
||||||
|
end
|
||||||
|
it("can read and write cdata with a registered ctype", function()
|
||||||
local value = ffi.new('struct some_struct', 42, 1.25)
|
local value = ffi.new('struct some_struct', 42, 1.25)
|
||||||
local type_of_struct = ffi.typeof(value)
|
bitser.register('struct_type', ffi.typeof(value))
|
||||||
-- with a registered type
|
|
||||||
bitser.register('struct_type', type_of_struct)
|
|
||||||
test_serdeser(value)
|
test_serdeser(value)
|
||||||
bitser.unregister('struct_type')
|
bitser.unregister('struct_type')
|
||||||
-- with an unregistered type
|
end)
|
||||||
|
it("can read and write cdata without registering its ctype", function()
|
||||||
|
local value = ffi.new('struct some_struct', 42, 1.25)
|
||||||
test_serdeser(value)
|
test_serdeser(value)
|
||||||
end)
|
end)
|
||||||
it("cannot read from anonymous structs", function()
|
it("cannot read from anonymous structs", function()
|
||||||
|
Loading…
Reference in New Issue
Block a user