@@ 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());
+}