16 lines
367 B
Zig
16 lines
367 B
Zig
const std = @import("std");
|
|
|
|
pub fn readShort(reader: anytype) !u16 {
|
|
//std.debug.print("read: readShort\n", .{});
|
|
return try reader.readIntBig(u16);
|
|
}
|
|
|
|
test "deserialize short" {
|
|
var bytes = &[_]u8{ 0x13, 0x12 };
|
|
var fBS = std.io.fixedBufferStream(bytes);
|
|
|
|
var short = try readShort(fBS.reader());
|
|
|
|
try std.testing.expect(short == 0x1312);
|
|
}
|