mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add test/data/cbor-rfc-7049-examples.*
This commit is contained in:
1 parent
77c7551b26
commit
1e96ef200c
7 files changed
+490
-5
No files matched your search
@@ -17,8 +17,10 @@
|
||||
package main
|
||||
|
||||
// extract-cbor-rfc-7049-examples.go extracts the examples (Appendix A) from
|
||||
// RFC 7049 "Concise Binary Object Representation (CBOR)". Each example is
|
||||
// written to a separate file under a "cbor-rfc-7049-examples" directory.
|
||||
// RFC 7049 "Concise Binary Object Representation (CBOR)". If the -concat flag
|
||||
// is passed, a single CBOR array containing all of the examples are written to
|
||||
// stdout. Otherwise, each example is written to a separate file under a
|
||||
// "cbor-rfc-7049-examples" directory.
|
||||
//
|
||||
// Usage:
|
||||
// go run extract-cbor-rfc-7049-examples.go < rfc7049-errata-corrected.txt
|
||||
@@ -31,11 +33,14 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
var concat = flag.Bool("concat", false, "output one monolithic CBOR file")
|
||||
|
||||
func main() {
|
||||
if err := main1(); err != nil {
|
||||
os.Stderr.WriteString(err.Error() + "\n")
|
||||
@@ -48,7 +53,10 @@ func main1() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := os.Mkdir("cbor-rfc-7049-examples", 0755); err != nil {
|
||||
if *concat {
|
||||
// Start of CBOR indefinite-length array.
|
||||
os.Stdout.Write([]byte("\x9F"))
|
||||
} else if err := os.Mkdir("cbor-rfc-7049-examples", 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
for remaining := []byte(nil); len(src) > 0; src = remaining {
|
||||
@@ -78,7 +86,14 @@ func main1() error {
|
||||
contents = append(contents, (unhex(src[0])<<4)|unhex(src[1]))
|
||||
}
|
||||
}
|
||||
return emit()
|
||||
if err := emit(); err != nil {
|
||||
return err
|
||||
}
|
||||
if *concat {
|
||||
// End of CBOR indefinite-length array.
|
||||
os.Stdout.Write([]byte("\xFF"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -90,6 +105,11 @@ func emit() error {
|
||||
if len(contents) == 0 {
|
||||
return nil
|
||||
}
|
||||
if *concat {
|
||||
os.Stdout.Write(contents)
|
||||
contents = nil
|
||||
return nil
|
||||
}
|
||||
filename := fmt.Sprintf("cbor-rfc-7049-examples/%02d.cbor", fileNumber)
|
||||
fileNumber++
|
||||
err := ioutil.WriteFile(filename, contents, 0644)
|
||||
|
||||
+15
-1
@@ -67,13 +67,27 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
// No mimic library.
|
||||
#endif
|
||||
|
||||
// ---------------- Golden Tests
|
||||
|
||||
golden_test g_cbor_cbor_rfc_7049_examples_gt = {
|
||||
.want_filename = "test/data/cbor-rfc-7049-examples.tokens",
|
||||
.src_filename = "test/data/cbor-rfc-7049-examples.cbor",
|
||||
};
|
||||
|
||||
// ---------------- CBOR Tests
|
||||
|
||||
const char* //
|
||||
test_wuffs_cbor_decode_interface() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
// TODO.
|
||||
wuffs_cbor__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_cbor__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
CHECK_STRING(do_test__wuffs_base__token_decoder(
|
||||
wuffs_cbor__decoder__upcast_as__wuffs_base__token_decoder(&dec),
|
||||
&g_cbor_cbor_rfc_7049_examples_gt));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ world examples of various file formats, or deriviations of them.
|
||||
`bricks-*` are various encodings of an original photo by Nigel Tao
|
||||
<nigeltao@golang.org>.
|
||||
|
||||
`cbor-rfc-7049-examples.cbor` is the concatenated examples from RFC 7049. The
|
||||
`cbor-rfc-7049-examples.*.json` files were then generated by `example/jsonptr`.
|
||||
|
||||
`crude-flag.*` is an original animation by Nigel Tao
|
||||
<nigeltao@golang.org>. See the `lib/nie` documentation.
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,224 @@
|
||||
[
|
||||
0,
|
||||
1,
|
||||
10,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
100,
|
||||
1000,
|
||||
1000000,
|
||||
1000000000000,
|
||||
18446744073709551615,
|
||||
"AQAAAAAAAAAA",
|
||||
-18446744073709551616,
|
||||
"AQAAAAAAAAAA",
|
||||
-1,
|
||||
-10,
|
||||
-100,
|
||||
-1000,
|
||||
0,
|
||||
-0,
|
||||
1,
|
||||
1.1,
|
||||
1.5,
|
||||
65504,
|
||||
100000,
|
||||
3.4028234663852886e+38,
|
||||
1e+300,
|
||||
5.960464477539063e-08,
|
||||
6.103515625e-05,
|
||||
-4,
|
||||
-4.1,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
"2013-03-21T20:04:00Z",
|
||||
1363896240,
|
||||
1.3638962405e+09,
|
||||
"AQIDBA",
|
||||
"ZElFVEY",
|
||||
"http://www.example.com",
|
||||
"",
|
||||
"AQIDBA",
|
||||
"",
|
||||
"a",
|
||||
"IETF",
|
||||
"\"\\",
|
||||
"ü",
|
||||
"水",
|
||||
"𐅑",
|
||||
[],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25
|
||||
],
|
||||
{},
|
||||
{
|
||||
"1": 2,
|
||||
"3": 4
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
[
|
||||
"a",
|
||||
{
|
||||
"b": "c"
|
||||
}
|
||||
],
|
||||
{
|
||||
"a": "A",
|
||||
"b": "B",
|
||||
"c": "C",
|
||||
"d": "D",
|
||||
"e": "E"
|
||||
},
|
||||
"AQIDBAU",
|
||||
"streaming",
|
||||
[],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25
|
||||
],
|
||||
{
|
||||
"a": 1,
|
||||
"b": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
[
|
||||
"a",
|
||||
{
|
||||
"b": "c"
|
||||
}
|
||||
],
|
||||
{
|
||||
"Fun": true,
|
||||
"Amt": -2
|
||||
}
|
||||
]
|
||||
Binary file not shown.
@@ -0,0 +1,224 @@
|
||||
[
|
||||
0,
|
||||
1,
|
||||
10,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
100,
|
||||
1000,
|
||||
1000000,
|
||||
1000000000000,
|
||||
18446744073709551615,
|
||||
/*cbor:tag2*//*cbor:base64url*/"AQAAAAAAAAAA",
|
||||
-18446744073709551616,
|
||||
/*cbor:tag3*//*cbor:base64url*/"AQAAAAAAAAAA",
|
||||
-1,
|
||||
-10,
|
||||
-100,
|
||||
-1000,
|
||||
0,
|
||||
-0,
|
||||
1,
|
||||
1.1,
|
||||
1.5,
|
||||
65504,
|
||||
100000,
|
||||
3.4028234663852886e+38,
|
||||
1e+300,
|
||||
5.960464477539063e-08,
|
||||
6.103515625e-05,
|
||||
-4,
|
||||
-4.1,
|
||||
/*cbor:Inf*/null,
|
||||
/*cbor:NaN*/null,
|
||||
/*cbor:-Inf*/null,
|
||||
/*cbor:Inf*/null,
|
||||
/*cbor:NaN*/null,
|
||||
/*cbor:-Inf*/null,
|
||||
/*cbor:Inf*/null,
|
||||
/*cbor:NaN*/null,
|
||||
/*cbor:-Inf*/null,
|
||||
false,
|
||||
true,
|
||||
null,
|
||||
/*cbor:undefined*/null,
|
||||
/*cbor:simple16*/null,
|
||||
/*cbor:simple24*/null,
|
||||
/*cbor:simple255*/null,
|
||||
/*cbor:tag0*/"2013-03-21T20:04:00Z",
|
||||
/*cbor:tag1*/1363896240,
|
||||
/*cbor:tag1*/1.3638962405e+09,
|
||||
/*cbor:tag23*//*cbor:base64url*/"AQIDBA",
|
||||
/*cbor:tag24*//*cbor:base64url*/"ZElFVEY",
|
||||
/*cbor:tag32*/"http://www.example.com",
|
||||
/*cbor:base64url*/"",
|
||||
/*cbor:base64url*/"AQIDBA",
|
||||
"",
|
||||
"a",
|
||||
"IETF",
|
||||
"\"\\",
|
||||
"ü",
|
||||
"水",
|
||||
"𐅑",
|
||||
[],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25
|
||||
],
|
||||
{},
|
||||
{
|
||||
"1": 2,
|
||||
"3": 4
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
[
|
||||
"a",
|
||||
{
|
||||
"b": "c"
|
||||
}
|
||||
],
|
||||
{
|
||||
"a": "A",
|
||||
"b": "B",
|
||||
"c": "C",
|
||||
"d": "D",
|
||||
"e": "E"
|
||||
},
|
||||
/*cbor:base64url*/"AQIDBAU",
|
||||
"streaming",
|
||||
[],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
[
|
||||
2,
|
||||
3
|
||||
],
|
||||
[
|
||||
4,
|
||||
5
|
||||
]
|
||||
],
|
||||
[
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25
|
||||
],
|
||||
{
|
||||
"a": 1,
|
||||
"b": [
|
||||
2,
|
||||
3
|
||||
]
|
||||
},
|
||||
[
|
||||
"a",
|
||||
{
|
||||
"b": "c"
|
||||
}
|
||||
],
|
||||
{
|
||||
"Fun": true,
|
||||
"Amt": -2
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user