Skip to content

Commit

Permalink
msgpack: Add str, array and object type tests
Browse files Browse the repository at this point in the history
Related to #634
  • Loading branch information
wader committed Apr 8, 2023
1 parent cd4974e commit 82da99c
Show file tree
Hide file tree
Showing 10 changed files with 1,020 additions and 13 deletions.
273 changes: 273 additions & 0 deletions format/msgpack/testdata/arrays.fqtest

Large diffs are not rendered by default.

Binary file added format/msgpack/testdata/arrays.msgpack
Binary file not shown.
8 changes: 0 additions & 8 deletions format/msgpack/testdata/fixstr.fqtest

This file was deleted.

30 changes: 29 additions & 1 deletion format/msgpack/testdata/ints.fqtest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fq -n '[0,1,2,3,4,5,6,7,8,9,127,128,-1,-2,-3,-4,-5,-6,-7,-8,-31,-32,0xffff_ffff,-0xffff_ffff,0x7fff_ffff,-0x7fff_ffff]' | json2msgpack > ints.msgpack
$ fq -d msgpack dv ints.msgpack
$ fq -d msgpack 'dv,torepr' ints.msgpack
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: ints.msgpack (msgpack) 0x0-0x31.7 (50)
0x00|dc |. | type: "array16" (0xdc) 0x0-0x0.7 (1)
0x00| 00 1a | .. | length: 26 0x1-0x2.7 (2)
Expand Down Expand Up @@ -83,6 +83,34 @@ $ fq -d msgpack dv ints.msgpack
0x20| d2 | . | type: "int32" (0xd2) 0x2d-0x2d.7 (1)
0x20| 80 00| ..| value: -2147483647 0x2e-0x31.7 (4)
0x30|00 01| |..| |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
127,
128,
-1,
-2,
-3,
-4,
-5,
-6,
-7,
-8,
-31,
-32,
4294967295,
-4294967295,
2147483647,
-2147483647
]
$ fq -d msgpack torepr ints.msgpack
[
0,
Expand Down
504 changes: 504 additions & 0 deletions format/msgpack/testdata/objects.fqtest

Large diffs are not rendered by default.

Binary file added format/msgpack/testdata/objects.msgpack
Binary file not shown.
211 changes: 211 additions & 0 deletions format/msgpack/testdata/strs.fqtest

Large diffs are not rendered by default.

Binary file added format/msgpack/testdata/strs.msgpack
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# msgpack-tools
# echo '{"array": [1,2,3], "object": {"key": "value"}, "number": 123, "string": "abc", "true": true, "false": false, "null": null}' | json2msgpack > test.msgpack
$ fq -d msgpack dv test.msgpack
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: test.msgpack (msgpack) 0x0-0x42.7 (67)
# echo '{"array": [1,2,3], "object": {"key": "value"}, "number": 123, "string": "abc", "true": true, "false": false, "null": null}' | json2msgpack > types.msgpack
$ fq -d msgpack 'dv,torepr' types.msgpack
|00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f|0123456789abcdef|.{}: types.msgpack (msgpack) 0x0-0x42.7 (67)
0x00|87 |. | type: "fixmap" (0x87) 0x0-0x0.7 (1)
0x00|87 |. | length: 7 0x0.4-0x0.7 (0.4)
| | | pairs[0:7]: 0x1-0x42.7 (66)
Expand Down Expand Up @@ -85,7 +85,6 @@ $ fq -d msgpack dv test.msgpack
| | | value{}: 0x42-0x42.7 (1)
0x40| c0| | .| | type: "nil" (0xc0) 0x42-0x42.7 (1)
| | | value: null 0x43-NA (0)
$ fq -d msgpack torepr test.msgpack
{
"array": [
1,
Expand Down
File renamed without changes.

0 comments on commit 82da99c

Please sign in to comment.