~alva/zig-bare

a4f465ed779b42562391118ca28ea53264bde37c — owl 5 months ago 12f8ceb
add go-bare marshal struct test
1 files changed, 14 insertions(+), 0 deletions(-)

M src/interop/go-bare/marshal_test.zig
M src/interop/go-bare/marshal_test.zig => src/interop/go-bare/marshal_test.zig +14 -0
@@ 83,3 83,17 @@ test "marshal optional" {
        try testing.expectEqualSlices(u8, &[_]u8{ 0x01, 0xEF, 0xBE, 0xAD, 0xDE }, fbs.getWritten());
    }
}

test "marshal struct" {
    var buf: [0x1_000]u8 = undefined;
    var fbs = io.fixedBufferStream(&buf);
    const writer = fbs.writer();
    var e = encoder(writer);

    const Coordinates = struct { x: usize, y: usize, z: usize };
    const coords = Coordinates{ .x = 1, .y = 2, .z = 3 };
    const reference = [_]u8{ 0x01, 0x02, 0x03 };

    try e.encode(coords);
    try testing.expectEqualSlices(u8, &reference, fbs.getWritten());
}