added deserialiser tests, fixed some bugs in deserialised
This commit is contained in:
parent
f454526c5a
commit
0275d67669
8 changed files with 267 additions and 93 deletions
40
tests/deserialise/root.zig
Normal file
40
tests/deserialise/root.zig
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub const binary = @import("binary.zig");
|
||||
pub const string = @import("string.zig");
|
||||
pub const int = @import("int.zig");
|
||||
|
||||
pub const msgpack = @import("msgpack");
|
||||
|
||||
const deserialise = msgpack.deserialise.deserialise;
|
||||
|
||||
test {
|
||||
@import("std").testing.refAllDecls(@This());
|
||||
}
|
||||
|
||||
test "nil" {
|
||||
const alloc = std.testing.allocator;
|
||||
|
||||
const obj = try deserialise(alloc, &[_]u8{0xc0});
|
||||
defer obj.deinit(alloc);
|
||||
|
||||
try std.testing.expectEqualDeep(msgpack.Object.nil, obj);
|
||||
}
|
||||
|
||||
test "bool" {
|
||||
const alloc = std.testing.allocator;
|
||||
|
||||
{
|
||||
const obj = try deserialise(alloc, &[_]u8{0xc2});
|
||||
defer obj.deinit(alloc);
|
||||
|
||||
try std.testing.expectEqualDeep(msgpack.Object{ .bool = false }, obj);
|
||||
}
|
||||
|
||||
{
|
||||
const obj = try deserialise(alloc, &[_]u8{0xc3});
|
||||
defer obj.deinit(alloc);
|
||||
|
||||
try std.testing.expectEqualDeep(msgpack.Object{ .bool = true }, obj);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue