2
2
#![ allow( clippy:: vec_init_then_push) ]
3
3
4
4
mod json;
5
- mod options;
6
5
7
6
use pretty_assertions:: assert_eq;
8
7
use serde:: {
@@ -19,7 +18,6 @@ use std::{
19
18
} ;
20
19
21
20
use bson:: {
22
- bson,
23
21
doc,
24
22
oid:: ObjectId ,
25
23
spec:: BinarySubtype ,
@@ -28,7 +26,6 @@ use bson::{
28
26
DateTime ,
29
27
Decimal128 ,
30
28
Deserializer ,
31
- DeserializerOptions ,
32
29
Document ,
33
30
JavaScriptCodeWithScope ,
34
31
RawArray ,
@@ -43,7 +40,6 @@ use bson::{
43
40
RawJavaScriptCodeWithScopeRef ,
44
41
RawRegexRef ,
45
42
Regex ,
46
- SerializerOptions ,
47
43
Timestamp ,
48
44
Uuid ,
49
45
} ;
86
82
description
87
83
) ;
88
84
89
- let non_human_readable_doc = bson:: to_document_with_options (
90
- & expected_value,
91
- #[ allow( deprecated) ]
92
- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
93
- )
94
- . expect ( description) ;
95
- assert_eq ! ( & non_human_readable_doc, expected_doc, "{}" , description) ;
96
- assert_eq ! (
97
- expected_value,
98
- & bson:: from_document_with_options:: <T >(
99
- non_human_readable_doc,
100
- #[ allow( deprecated) ]
101
- DeserializerOptions :: builder( ) . human_readable( false ) . build( )
102
- )
103
- . expect( description) ,
104
- "{}" ,
105
- description
106
- ) ;
107
-
108
85
assert_eq ! (
109
86
& bson:: from_reader:: <_, T >( expected_bytes. as_slice( ) ) . expect( description) ,
110
87
expected_value,
@@ -1353,62 +1330,6 @@ fn hint_cleared() {
1353
1330
assert_eq ! ( round_doc, doc! { "doc" : doc_value, "binary" : binary_value } ) ;
1354
1331
}
1355
1332
1356
- #[ test]
1357
- fn non_human_readable ( ) {
1358
- let bytes = vec ! [ 1 , 2 , 3 , 4 ] ;
1359
- let binary = RawBinaryRef {
1360
- bytes : & bytes,
1361
- subtype : BinarySubtype :: BinaryOld ,
1362
- } ;
1363
-
1364
- let doc_bytes = bson:: to_vec ( & doc ! { "a" : "b" , "array" : [ 1 , 2 , 3 ] } ) . unwrap ( ) ;
1365
- let doc = RawDocument :: from_bytes ( doc_bytes. as_slice ( ) ) . unwrap ( ) ;
1366
- let arr = doc. get_array ( "array" ) . unwrap ( ) ;
1367
- let oid = ObjectId :: new ( ) ;
1368
- let uuid = Uuid :: new ( ) ;
1369
-
1370
- #[ derive( Debug , Deserialize , Serialize ) ]
1371
- struct Foo < ' a > {
1372
- #[ serde( borrow) ]
1373
- binary : RawBinaryRef < ' a > ,
1374
- #[ serde( borrow) ]
1375
- doc : & ' a RawDocument ,
1376
- #[ serde( borrow) ]
1377
- arr : & ' a RawArray ,
1378
- oid : ObjectId ,
1379
- uuid : Uuid ,
1380
- }
1381
-
1382
- let val = Foo {
1383
- binary,
1384
- doc,
1385
- arr,
1386
- oid,
1387
- uuid,
1388
- } ;
1389
-
1390
- let human_readable = bson:: to_bson ( & val) . unwrap ( ) ;
1391
- let non_human_readable = bson:: to_bson_with_options (
1392
- & val,
1393
- #[ allow( deprecated) ]
1394
- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
1395
- )
1396
- . unwrap ( ) ;
1397
-
1398
- let expected = bson ! ( {
1399
- "binary" : Binary { bytes: bytes. clone( ) , subtype: BinarySubtype :: BinaryOld } ,
1400
- "doc" : {
1401
- "a" : "b" ,
1402
- "array" : [ 1 , 2 , 3 ] ,
1403
- } ,
1404
- "arr" : [ 1 , 2 , 3 ] ,
1405
- "oid" : oid,
1406
- "uuid" : uuid
1407
- } ) ;
1408
- assert_eq ! ( human_readable, expected) ;
1409
- assert_eq ! ( human_readable, non_human_readable) ;
1410
- }
1411
-
1412
1333
#[ test]
1413
1334
fn invalid_length ( ) {
1414
1335
// This is a regression test for fuzzer-generated input (RUST-1240).
0 commit comments