serialiser
This commit is contained in:
parent
113f49f6a4
commit
e1f1084a39
14 changed files with 698 additions and 51 deletions
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
|
||||
const msgpack = @import("msgpack");
|
||||
|
||||
const deserialise = msgpack.deserialise.deserialise;
|
||||
const deserialise = msgpack.deserialise;
|
||||
|
||||
fn test_binary(bytes: []const u8, expected: []const u8) !void {
|
||||
const alloc = std.testing.allocator;
|
||||
|
|
@ -10,22 +10,22 @@ fn test_binary(bytes: []const u8, expected: []const u8) !void {
|
|||
const obj = try deserialise(alloc, bytes);
|
||||
defer obj.deinit(alloc);
|
||||
|
||||
try std.testing.expectEqualStrings(expected, obj.raw.binary);
|
||||
try std.testing.expectEqualStrings(expected, obj.binary);
|
||||
}
|
||||
|
||||
test "binary 1" {
|
||||
test "fixbin" {
|
||||
const bytes = [_]u8{ 0xc4, 0x03, 'A', 'B', 'C' };
|
||||
|
||||
try test_binary(&bytes, "ABC");
|
||||
}
|
||||
|
||||
test "binary 2" {
|
||||
test "empty bin" {
|
||||
const bytes = [_]u8{ 0xc4, 0x00 };
|
||||
|
||||
try test_binary(&bytes, "");
|
||||
}
|
||||
|
||||
test "binary 3" {
|
||||
test "bin8" {
|
||||
var bytes: [2 + 255]u8 = undefined;
|
||||
|
||||
bytes[0] = 0xc4;
|
||||
|
|
@ -38,7 +38,7 @@ test "binary 3" {
|
|||
try test_binary(&bytes, "A" ** 255);
|
||||
}
|
||||
|
||||
test "binary 4" {
|
||||
test "bin16 1" {
|
||||
var bytes: [3 + 256]u8 = undefined;
|
||||
|
||||
bytes[0] = 0xc5;
|
||||
|
|
@ -52,7 +52,7 @@ test "binary 4" {
|
|||
try test_binary(&bytes, "A" ** 256);
|
||||
}
|
||||
|
||||
test "binary 5" {
|
||||
test "bin16 2" {
|
||||
var bytes: [3 + 65535]u8 = undefined;
|
||||
|
||||
bytes[0] = 0xc5;
|
||||
|
|
@ -66,7 +66,7 @@ test "binary 5" {
|
|||
try test_binary(&bytes, "A" ** 65535);
|
||||
}
|
||||
|
||||
test "binary 6" {
|
||||
test "bin32" {
|
||||
var bytes: [5 + 65536]u8 = undefined;
|
||||
|
||||
bytes[0] = 0xc6;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue