refactor: add some more byte level scalar encoding tests
This commit is contained in:
parent
cc32dd2075
commit
301e96f75d
1 changed files with 25 additions and 0 deletions
|
|
@ -459,6 +459,31 @@ test "cbor.toJsonPretty_object" {
|
|||
);
|
||||
}
|
||||
|
||||
test "cbor encode int 1byte" {
|
||||
var buf: [16]u8 = undefined;
|
||||
try expectEqualDeep(fmt(&buf, @as(i64, 26)), &[_]u8{ 0x18, 0x1A });
|
||||
}
|
||||
|
||||
test "cbor encode int 2byte" {
|
||||
var buf: [16]u8 = undefined;
|
||||
try expectEqualDeep(fmt(&buf, @as(i64, 263)), &[_]u8{ 0x19, 0x01, 0x07 });
|
||||
}
|
||||
|
||||
test "cbor encode int 4byte" {
|
||||
var buf: [16]u8 = undefined;
|
||||
try expectEqualDeep(fmt(&buf, @as(i64, 65536)), &[_]u8{ 0x1A, 0x00, 0x01, 0x00, 0x00 });
|
||||
}
|
||||
|
||||
test "cbor encode int 8byte" {
|
||||
var buf: [16]u8 = undefined;
|
||||
try expectEqualDeep(fmt(&buf, @as(i64, 263263263263263)), &[_]u8{ 0x1B, 0x00, 0x00, 0xEF, 0x6F, 0xC1, 0x4A, 0x0A, 0x1F });
|
||||
}
|
||||
|
||||
test "cbor encode f16" {
|
||||
var buf: [16]u8 = undefined;
|
||||
try expectEqualDeep(fmt(&buf, @as(f16, 1.5)), &[_]u8{ 0xF9, 0x3E, 0x00 });
|
||||
}
|
||||
|
||||
test "cbor.fromJson_small" {
|
||||
var cbor_buf: [128]u8 = undefined;
|
||||
const json_buf: []const u8 =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue