summaryrefslogtreecommitdiffstats
path: root/vendor/serde_json/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/serde_json/tests
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/serde_json/tests')
-rw-r--r--vendor/serde_json/tests/lexical.rs1
-rw-r--r--vendor/serde_json/tests/regression/issue1004.rs12
-rw-r--r--vendor/serde_json/tests/test.rs22
3 files changed, 35 insertions, 0 deletions
diff --git a/vendor/serde_json/tests/lexical.rs b/vendor/serde_json/tests/lexical.rs
index 6e0f07b8c..d3dfb852b 100644
--- a/vendor/serde_json/tests/lexical.rs
+++ b/vendor/serde_json/tests/lexical.rs
@@ -9,6 +9,7 @@
clippy::excessive_precision,
clippy::float_cmp,
clippy::if_not_else,
+ clippy::let_underscore_untyped,
clippy::module_name_repetitions,
clippy::needless_late_init,
clippy::shadow_unrelated,
diff --git a/vendor/serde_json/tests/regression/issue1004.rs b/vendor/serde_json/tests/regression/issue1004.rs
new file mode 100644
index 000000000..3f5bd96aa
--- /dev/null
+++ b/vendor/serde_json/tests/regression/issue1004.rs
@@ -0,0 +1,12 @@
+#![cfg(feature = "arbitrary_precision")]
+
+#[test]
+fn test() {
+ let float = 5.55f32;
+ let value = serde_json::to_value(&float).unwrap();
+ let json = serde_json::to_string(&value).unwrap();
+
+ // If the f32 were cast to f64 by Value before serialization, then this
+ // would incorrectly serialize as 5.550000190734863.
+ assert_eq!(json, "5.55");
+}
diff --git a/vendor/serde_json/tests/test.rs b/vendor/serde_json/tests/test.rs
index c2050724b..6c08cc8d2 100644
--- a/vendor/serde_json/tests/test.rs
+++ b/vendor/serde_json/tests/test.rs
@@ -6,6 +6,7 @@
clippy::excessive_precision,
clippy::float_cmp,
clippy::items_after_statements,
+ clippy::let_underscore_untyped,
clippy::shadow_unrelated,
clippy::too_many_lines,
clippy::unreadable_literal,
@@ -2180,6 +2181,27 @@ fn test_integer128() {
]);
}
+#[test]
+fn test_integer128_to_value() {
+ let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())];
+ let unsigned = &[0, u128::from(u64::max_value())];
+
+ for integer128 in signed {
+ let expected = integer128.to_string();
+ assert_eq!(to_value(integer128).unwrap().to_string(), expected);
+ }
+
+ for integer128 in unsigned {
+ let expected = integer128.to_string();
+ assert_eq!(to_value(integer128).unwrap().to_string(), expected);
+ }
+
+ if !cfg!(feature = "arbitrary_precision") {
+ let err = to_value(u128::from(u64::max_value()) + 1).unwrap_err();
+ assert_eq!(err.to_string(), "number out of range");
+ }
+}
+
#[cfg(feature = "raw_value")]
#[test]
fn test_borrowed_raw_value() {