Skip to content

Commit f583d51

Browse files
committed
test(msgpack): add comprehensive constant validation tests
- validate FixLimits constants for primitive type ranges - verify IntBounds constants for integer min/max values - test FixExtLen constants for extension length markers - confirm TimestampExt constants for timestamp formatting - validate MarkerBase constants for MessagePack type markers
1 parent 7a30557 commit f583d51

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

src/test.zig

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,48 @@ test "actual map32 format" {
12951295
try expect(try last_value.?.getInt() == 999);
12961296
}
12971297

1298+
// Test constant structures values
1299+
test "constant structures validation" {
1300+
// Test FixLimits constants
1301+
try expect(msgpack.FixLimits.POSITIVE_INT_MAX == 0x7f);
1302+
try expect(msgpack.FixLimits.NEGATIVE_INT_MIN == -32);
1303+
try expect(msgpack.FixLimits.STR_LEN_MAX == 31);
1304+
try expect(msgpack.FixLimits.ARRAY_LEN_MAX == 15);
1305+
try expect(msgpack.FixLimits.MAP_LEN_MAX == 15);
1306+
1307+
// Test IntBounds constants
1308+
try expect(msgpack.IntBounds.UINT8_MAX == 0xff);
1309+
try expect(msgpack.IntBounds.UINT16_MAX == 0xffff);
1310+
try expect(msgpack.IntBounds.UINT32_MAX == 0xffff_ffff);
1311+
try expect(msgpack.IntBounds.INT8_MIN == -128);
1312+
try expect(msgpack.IntBounds.INT16_MIN == -32768);
1313+
try expect(msgpack.IntBounds.INT32_MIN == -2147483648);
1314+
1315+
// Test FixExtLen constants
1316+
try expect(msgpack.FixExtLen.EXT1 == 1);
1317+
try expect(msgpack.FixExtLen.EXT2 == 2);
1318+
try expect(msgpack.FixExtLen.EXT4 == 4);
1319+
try expect(msgpack.FixExtLen.EXT8 == 8);
1320+
try expect(msgpack.FixExtLen.EXT16 == 16);
1321+
1322+
// Test TimestampExt constants
1323+
try expect(msgpack.TimestampExt.TYPE_ID == -1);
1324+
try expect(msgpack.TimestampExt.FORMAT32_LEN == 4);
1325+
try expect(msgpack.TimestampExt.FORMAT64_LEN == 8);
1326+
try expect(msgpack.TimestampExt.FORMAT96_LEN == 12);
1327+
try expect(msgpack.TimestampExt.SECONDS_BITS_64 == 34);
1328+
try expect(msgpack.TimestampExt.SECONDS_MASK_64 == 0x3ffffffff);
1329+
try expect(msgpack.TimestampExt.NANOSECONDS_MAX == 999_999_999);
1330+
try expect(msgpack.TimestampExt.NANOSECONDS_PER_SECOND == 1_000_000_000.0);
1331+
1332+
// Test MarkerBase constants
1333+
try expect(msgpack.MarkerBase.FIXARRAY == 0x90);
1334+
try expect(msgpack.MarkerBase.FIXMAP == 0x80);
1335+
try expect(msgpack.MarkerBase.FIXSTR == 0xa0);
1336+
try expect(msgpack.MarkerBase.FIXSTR_LEN_MASK == 0x1f);
1337+
try expect(msgpack.MarkerBase.FIXSTR_TYPE_MASK == 0xe0);
1338+
}
1339+
12981340
// Test edge cases and error conditions
12991341
test "edge cases and error conditions" {
13001342
var arr: [100]u8 = std.mem.zeroes([100]u8);

0 commit comments

Comments
 (0)