msgpack-zig/tests/deserialise/root.zig

40 lines
932 B
Zig

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);
}
}