summaryrefslogtreecommitdiffstats
path: root/vendor/serde_json/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/serde_json/tests')
-rw-r--r--vendor/serde_json/tests/debug.rs43
-rw-r--r--vendor/serde_json/tests/regression/issue795.rs2
-rw-r--r--vendor/serde_json/tests/stream.rs1
-rw-r--r--vendor/serde_json/tests/test.rs1
-rw-r--r--vendor/serde_json/tests/ui/missing_colon.stderr2
-rw-r--r--vendor/serde_json/tests/ui/missing_value.stderr2
6 files changed, 34 insertions, 17 deletions
diff --git a/vendor/serde_json/tests/debug.rs b/vendor/serde_json/tests/debug.rs
index d2d8448be..8ddcf5a38 100644
--- a/vendor/serde_json/tests/debug.rs
+++ b/vendor/serde_json/tests/debug.rs
@@ -1,3 +1,4 @@
+use indoc::indoc;
use serde_json::{json, Number, Value};
#[test]
@@ -26,6 +27,8 @@ fn value_number() {
assert_eq!(format!("{:?}", json!(1)), "Number(1)");
assert_eq!(format!("{:?}", json!(-1)), "Number(-1)");
assert_eq!(format!("{:?}", json!(1.0)), "Number(1.0)");
+ assert_eq!(Number::from_f64(1.0).unwrap().to_string(), "1.0"); // not just "1"
+ assert_eq!(Number::from_f64(12e40).unwrap().to_string(), "1.2e41");
}
#[test]
@@ -35,12 +38,12 @@ fn value_string() {
#[test]
fn value_array() {
- assert_eq!(format!("{:?}", json!([])), "Array([])");
+ assert_eq!(format!("{:?}", json!([])), "Array []");
}
#[test]
fn value_object() {
- assert_eq!(format!("{:?}", json!({})), "Object({})");
+ assert_eq!(format!("{:?}", json!({})), "Object {}");
}
#[test]
@@ -50,19 +53,29 @@ fn error() {
assert_eq!(format!("{:?}", err), expected);
}
-const INDENTED_EXPECTED: &str = r#"Object({
- "array": Array([
- Number(
- 0,
- ),
- Number(
- 1,
- ),
- ]),
-})"#;
-
#[test]
fn indented() {
- let j = json!({ "array": [0, 1] });
- assert_eq!(format!("{:#?}", j), INDENTED_EXPECTED);
+ let j = json!({
+ "Array": [true],
+ "Bool": true,
+ "EmptyArray": [],
+ "EmptyObject": {},
+ "Null": null,
+ "Number": 1,
+ "String": "...",
+ });
+ let expected = indoc! {r#"
+ Object {
+ "Array": Array [
+ Bool(true),
+ ],
+ "Bool": Bool(true),
+ "EmptyArray": Array [],
+ "EmptyObject": Object {},
+ "Null": Null,
+ "Number": Number(1),
+ "String": String("..."),
+ }"#
+ };
+ assert_eq!(format!("{:#?}", j), expected);
}
diff --git a/vendor/serde_json/tests/regression/issue795.rs b/vendor/serde_json/tests/regression/issue795.rs
index 06b68724e..bb82852c5 100644
--- a/vendor/serde_json/tests/regression/issue795.rs
+++ b/vendor/serde_json/tests/regression/issue795.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::assertions_on_result_states)]
+
use serde::de::{
Deserialize, Deserializer, EnumAccess, IgnoredAny, MapAccess, VariantAccess, Visitor,
};
diff --git a/vendor/serde_json/tests/stream.rs b/vendor/serde_json/tests/stream.rs
index ca54e9a15..ec6b9e3d0 100644
--- a/vendor/serde_json/tests/stream.rs
+++ b/vendor/serde_json/tests/stream.rs
@@ -1,4 +1,5 @@
#![cfg(not(feature = "preserve_order"))]
+#![allow(clippy::assertions_on_result_states)]
use serde_json::{json, Deserializer, Value};
diff --git a/vendor/serde_json/tests/test.rs b/vendor/serde_json/tests/test.rs
index 13d30c490..0aeaff88d 100644
--- a/vendor/serde_json/tests/test.rs
+++ b/vendor/serde_json/tests/test.rs
@@ -1,5 +1,6 @@
#![cfg(not(feature = "preserve_order"))]
#![allow(
+ clippy::assertions_on_result_states,
clippy::cast_precision_loss,
clippy::derive_partial_eq_without_eq,
clippy::excessive_precision,
diff --git a/vendor/serde_json/tests/ui/missing_colon.stderr b/vendor/serde_json/tests/ui/missing_colon.stderr
index 9b83c1777..3cebc4fd3 100644
--- a/vendor/serde_json/tests/ui/missing_colon.stderr
+++ b/vendor/serde_json/tests/ui/missing_colon.stderr
@@ -4,4 +4,4 @@ error: unexpected end of macro invocation
4 | json!({ "a" });
| ^^^^^^^^^^^^^^ missing tokens in macro arguments
|
- = note: this error originates in the macro `json_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `json_internal` which comes from the expansion of the macro `json` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/vendor/serde_json/tests/ui/missing_value.stderr b/vendor/serde_json/tests/ui/missing_value.stderr
index d538d9613..a1edbc37b 100644
--- a/vendor/serde_json/tests/ui/missing_value.stderr
+++ b/vendor/serde_json/tests/ui/missing_value.stderr
@@ -4,4 +4,4 @@ error: unexpected end of macro invocation
4 | json!({ "a" : });
| ^^^^^^^^^^^^^^^^ missing tokens in macro arguments
|
- = note: this error originates in the macro `json_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
+ = note: this error originates in the macro `json_internal` which comes from the expansion of the macro `json` (in Nightly builds, run with -Z macro-backtrace for more info)