@@ -125,6 +125,7 @@ func TestExtJSONParserPeekType(t *testing.T) {
125
125
makeValidPeekTypeTestCase (`{"$binary": {"base64": "AQIDBAU=", "subType": "80"}}` , bsontype .Binary , "Binary" ),
126
126
makeValidPeekTypeTestCase (`{"$code": "function() {}", "$scope": {}}` , bsontype .CodeWithScope , "Code With Scope" ),
127
127
makeValidPeekTypeTestCase (`{"$binary": {"base64": "o0w498Or7cijeBSpkquNtg==", "subType": "03"}}` , bsontype .Binary , "Binary" ),
128
+ makeValidPeekTypeTestCase (`{"$binary": "o0w498Or7cijeBSpkquNtg==", "$type": "03"}` , bsontype .Binary , "Binary" ),
128
129
makeValidPeekTypeTestCase (`{"$regularExpression": {"pattern": "foo*", "options": "ix"}}` , bsontype .Regex , "Regular expression" ),
129
130
makeValidPeekTypeTestCase (`{"$dbPointer": {"$ref": "db.collection", "$id": {"$oid": "57e193d7a9cc81b4027498b1"}}}` , bsontype .DBPointer , "DBPointer" ),
130
131
makeValidPeekTypeTestCase (`{"$ref": "collection", "$id": {"$oid": "57fd71e96e32ab4225b723fb"}, "$db": "database"}` , bsontype .EmbeddedDocument , "DBRef" ),
@@ -344,8 +345,8 @@ func expectMultipleValues(t *testing.T, p *extJSONParser, expectedKey string, ex
344
345
readKeyDiff (t , expectedKey , k , expectedType , typ , err , expectNoError , expectedKey )
345
346
346
347
v , err := p .readValue (typ )
347
- typDiff (t , bsontype .EmbeddedDocument , v .t , expectedKey )
348
348
expectNoError (t , err , "" )
349
+ typDiff (t , bsontype .EmbeddedDocument , v .t , expectedKey )
349
350
350
351
actObj := v .v .(* extJSONObject )
351
352
expObj := expectedValue .(* extJSONObject )
@@ -445,6 +446,7 @@ func TestExtJSONParserAllTypes(t *testing.T) {
445
446
, "SpecialFloat" : { "$numberDouble": "NaN" }
446
447
, "Decimal" : { "$numberDecimal": "1234" }
447
448
, "Binary" : { "$binary": { "base64": "o0w498Or7cijeBSpkquNtg==", "subType": "03" } }
449
+ , "BinaryLegacy" : { "$binary": "o0w498Or7cijeBSpkquNtg==", "$type": "03" }
448
450
, "BinaryUserDefined" : { "$binary": { "base64": "AQIDBAU=", "subType": "80" } }
449
451
, "Code" : { "$code": "function() {}" }
450
452
, "CodeWithEmptyScope" : { "$code": "function() {}", "$scope": {} }
@@ -514,6 +516,17 @@ func TestExtJSONParserAllTypes(t *testing.T) {
514
516
},
515
517
},
516
518
},
519
+ {
520
+ f : expectMultipleValues , p : ejp ,
521
+ k : "BinaryLegacy" , t : bsontype .Binary ,
522
+ v : & extJSONObject {
523
+ keys : []string {"base64" , "subType" },
524
+ values : []* extJSONValue {
525
+ {t : bsontype .String , v : "o0w498Or7cijeBSpkquNtg==" },
526
+ {t : bsontype .String , v : "03" },
527
+ },
528
+ },
529
+ },
517
530
{
518
531
f : expectMultipleValues , p : ejp ,
519
532
k : "BinaryUserDefined" , t : bsontype .Binary ,
0 commit comments