Skip to content

Commit 45c1b13

Browse files
authored
RUST-665 Sync spec tests for dots and dollars in keys (#275)
1 parent 44f6456 commit 45c1b13

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

src/tests/spec/json/bson-corpus/document.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@
1717
"description": "Single-character key subdoc",
1818
"canonical_bson": "160000000378000E0000000261000200000062000000",
1919
"canonical_extjson": "{\"x\" : {\"a\" : \"b\"}}"
20+
},
21+
{
22+
"description": "Dollar-prefixed key in sub-document",
23+
"canonical_bson": "170000000378000F000000022461000200000062000000",
24+
"canonical_extjson": "{\"x\" : {\"$a\" : \"b\"}}"
25+
},
26+
{
27+
"description": "Dollar as key in sub-document",
28+
"canonical_bson": "160000000378000E0000000224000200000061000000",
29+
"canonical_extjson": "{\"x\" : {\"$\" : \"a\"}}"
30+
},
31+
{
32+
"description": "Dotted key in sub-document",
33+
"canonical_bson": "180000000378001000000002612E62000200000063000000",
34+
"canonical_extjson": "{\"x\" : {\"a.b\" : \"c\"}}"
35+
},
36+
{
37+
"description": "Dot as key in sub-document",
38+
"canonical_bson": "160000000378000E000000022E000200000061000000",
39+
"canonical_extjson": "{\"x\" : {\".\" : \"a\"}}"
2040
}
2141
],
2242
"decodeErrors": [

src/tests/spec/json/bson-corpus/top.json

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,24 @@
33
"bson_type": "0x00",
44
"valid": [
55
{
6-
"description": "Document with keys that start with $",
6+
"description": "Dollar-prefixed key in top-level document",
77
"canonical_bson": "0F00000010246B6579002A00000000",
88
"canonical_extjson": "{\"$key\": {\"$numberInt\": \"42\"}}"
9+
},
10+
{
11+
"description": "Dollar as key in top-level document",
12+
"canonical_bson": "0E00000002240002000000610000",
13+
"canonical_extjson": "{\"$\": \"a\"}"
14+
},
15+
{
16+
"description": "Dotted key in top-level document",
17+
"canonical_bson": "1000000002612E620002000000630000",
18+
"canonical_extjson": "{\"a.b\": \"c\"}"
19+
},
20+
{
21+
"description": "Dot as key in top-level document",
22+
"canonical_bson": "0E000000022E0002000000610000",
23+
"canonical_extjson": "{\".\": \"a\"}"
924
}
1025
],
1126
"decodeErrors": [
@@ -199,14 +214,6 @@
199214
"description": "Bad $date (extra field)",
200215
"string": "{\"a\" : {\"$date\" : {\"$numberLong\" : \"1356351330501\"}, \"unrelated\": true}}"
201216
},
202-
{
203-
"description": "Bad DBRef (ref is number, not string)",
204-
"string": "{\"x\" : {\"$ref\" : 42, \"$id\" : \"abc\"}}"
205-
},
206-
{
207-
"description": "Bad DBRef (db is number, not string)",
208-
"string": "{\"x\" : {\"$ref\" : \"a\", \"$id\" : \"abc\", \"$db\" : 42}}"
209-
},
210217
{
211218
"description": "Bad $minKey (boolean, not integer)",
212219
"string": "{\"a\" : {\"$minKey\" : true}}"

0 commit comments

Comments
 (0)