Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
218 changes: 0 additions & 218 deletions serde-tests/options.rs

This file was deleted.

79 changes: 0 additions & 79 deletions serde-tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(clippy::vec_init_then_push)]

mod json;
mod options;

use pretty_assertions::assert_eq;
use serde::{
Expand All @@ -19,7 +18,6 @@ use std::{
};

use bson::{
bson,
doc,
oid::ObjectId,
spec::BinarySubtype,
Expand All @@ -28,7 +26,6 @@ use bson::{
DateTime,
Decimal128,
Deserializer,
DeserializerOptions,
Document,
JavaScriptCodeWithScope,
RawArray,
Expand All @@ -43,7 +40,6 @@ use bson::{
RawJavaScriptCodeWithScopeRef,
RawRegexRef,
Regex,
SerializerOptions,
Timestamp,
Uuid,
};
Expand Down Expand Up @@ -86,25 +82,6 @@ where
description
);

let non_human_readable_doc = bson::to_document_with_options(
&expected_value,
#[allow(deprecated)]
SerializerOptions::builder().human_readable(false).build(),
)
.expect(description);
assert_eq!(&non_human_readable_doc, expected_doc, "{}", description);
assert_eq!(
expected_value,
&bson::from_document_with_options::<T>(
non_human_readable_doc,
#[allow(deprecated)]
DeserializerOptions::builder().human_readable(false).build()
)
.expect(description),
"{}",
description
);

assert_eq!(
&bson::from_reader::<_, T>(expected_bytes.as_slice()).expect(description),
expected_value,
Expand Down Expand Up @@ -1353,62 +1330,6 @@ fn hint_cleared() {
assert_eq!(round_doc, doc! { "doc": doc_value, "binary": binary_value });
}

#[test]
fn non_human_readable() {
let bytes = vec![1, 2, 3, 4];
let binary = RawBinaryRef {
bytes: &bytes,
subtype: BinarySubtype::BinaryOld,
};

let doc_bytes = bson::to_vec(&doc! { "a": "b", "array": [1, 2, 3] }).unwrap();
let doc = RawDocument::from_bytes(doc_bytes.as_slice()).unwrap();
let arr = doc.get_array("array").unwrap();
let oid = ObjectId::new();
let uuid = Uuid::new();

#[derive(Debug, Deserialize, Serialize)]
struct Foo<'a> {
#[serde(borrow)]
binary: RawBinaryRef<'a>,
#[serde(borrow)]
doc: &'a RawDocument,
#[serde(borrow)]
arr: &'a RawArray,
oid: ObjectId,
uuid: Uuid,
}

let val = Foo {
binary,
doc,
arr,
oid,
uuid,
};

let human_readable = bson::to_bson(&val).unwrap();
let non_human_readable = bson::to_bson_with_options(
&val,
#[allow(deprecated)]
SerializerOptions::builder().human_readable(false).build(),
)
.unwrap();

let expected = bson!({
"binary": Binary { bytes: bytes.clone(), subtype: BinarySubtype::BinaryOld },
"doc": {
"a": "b",
"array": [1, 2, 3],
},
"arr": [1, 2, 3],
"oid": oid,
"uuid": uuid
});
assert_eq!(human_readable, expected);
assert_eq!(human_readable, non_human_readable);
}

#[test]
fn invalid_length() {
// This is a regression test for fuzzer-generated input (RUST-1240).
Expand Down
Loading