aboutsummaryrefslogtreecommitdiff
path: root/vendor/serde_json/tests/regression
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/serde_json/tests/regression')
-rw-r--r--vendor/serde_json/tests/regression/issue1004.rs12
-rw-r--r--vendor/serde_json/tests/regression/issue520.rs20
-rw-r--r--vendor/serde_json/tests/regression/issue795.rs59
-rw-r--r--vendor/serde_json/tests/regression/issue845.rs73
-rw-r--r--vendor/serde_json/tests/regression/issue953.rs9
5 files changed, 0 insertions, 173 deletions
diff --git a/vendor/serde_json/tests/regression/issue1004.rs b/vendor/serde_json/tests/regression/issue1004.rs
deleted file mode 100644
index c09fb96..0000000
--- a/vendor/serde_json/tests/regression/issue1004.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![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/regression/issue520.rs b/vendor/serde_json/tests/regression/issue520.rs
deleted file mode 100644
index 9ed3677..0000000
--- a/vendor/serde_json/tests/regression/issue520.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-#![allow(clippy::float_cmp)]
-
-use serde_derive::{Serialize, Deserialize};
-
-#[derive(Serialize, Deserialize, Debug)]
-#[serde(tag = "type", content = "data")]
-enum E {
- Float(f32),
-}
-
-#[test]
-fn test() {
- let e = E::Float(159.1);
- let v = serde_json::to_value(e).unwrap();
- let e = serde_json::from_value::<E>(v).unwrap();
-
- match e {
- E::Float(f) => assert_eq!(f, 159.1),
- }
-}
diff --git a/vendor/serde_json/tests/regression/issue795.rs b/vendor/serde_json/tests/regression/issue795.rs
deleted file mode 100644
index bb82852..0000000
--- a/vendor/serde_json/tests/regression/issue795.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-#![allow(clippy::assertions_on_result_states)]
-
-use serde::de::{
- Deserialize, Deserializer, EnumAccess, IgnoredAny, MapAccess, VariantAccess, Visitor,
-};
-use serde_json::json;
-use std::fmt;
-
-#[derive(Debug)]
-pub enum Enum {
- Variant { x: u8 },
-}
-
-impl<'de> Deserialize<'de> for Enum {
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
- where
- D: Deserializer<'de>,
- {
- struct EnumVisitor;
-
- impl<'de> Visitor<'de> for EnumVisitor {
- type Value = Enum;
-
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("enum Enum")
- }
-
- fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
- where
- A: EnumAccess<'de>,
- {
- let (IgnoredAny, variant) = data.variant()?;
- variant.struct_variant(&["x"], self)
- }
-
- fn visit_map<A>(self, mut data: A) -> Result<Self::Value, A::Error>
- where
- A: MapAccess<'de>,
- {
- let mut x = 0;
- if let Some((IgnoredAny, value)) = data.next_entry()? {
- x = value;
- }
- Ok(Enum::Variant { x })
- }
- }
-
- deserializer.deserialize_enum("Enum", &["Variant"], EnumVisitor)
- }
-}
-
-#[test]
-fn test() {
- let s = r#" {"Variant":{"x":0,"y":0}} "#;
- assert!(serde_json::from_str::<Enum>(s).is_err());
-
- let j = json!({"Variant":{"x":0,"y":0}});
- assert!(serde_json::from_value::<Enum>(j).is_err());
-}
diff --git a/vendor/serde_json/tests/regression/issue845.rs b/vendor/serde_json/tests/regression/issue845.rs
deleted file mode 100644
index e8b0c0f..0000000
--- a/vendor/serde_json/tests/regression/issue845.rs
+++ /dev/null
@@ -1,73 +0,0 @@
-#![allow(clippy::trait_duplication_in_bounds)] // https://github.com/rust-lang/rust-clippy/issues/8757
-
-use serde::{Deserialize, Deserializer};
-use std::fmt::{self, Display};
-use std::marker::PhantomData;
-use std::str::FromStr;
-
-pub struct NumberVisitor<T> {
- marker: PhantomData<T>,
-}
-
-impl<'de, T> serde::de::Visitor<'de> for NumberVisitor<T>
-where
- T: TryFrom<u64> + TryFrom<i64> + FromStr,
- <T as TryFrom<u64>>::Error: Display,
- <T as TryFrom<i64>>::Error: Display,
- <T as FromStr>::Err: Display,
-{
- type Value = T;
-
- fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
- formatter.write_str("an integer or string")
- }
-
- fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
- where
- E: serde::de::Error,
- {
- T::try_from(v).map_err(serde::de::Error::custom)
- }
-
- fn visit_i64<E>(self, v: i64) -> Result<Self::Value, E>
- where
- E: serde::de::Error,
- {
- T::try_from(v).map_err(serde::de::Error::custom)
- }
-
- fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
- where
- E: serde::de::Error,
- {
- v.parse().map_err(serde::de::Error::custom)
- }
-}
-
-fn deserialize_integer_or_string<'de, D, T>(deserializer: D) -> Result<T, D::Error>
-where
- D: Deserializer<'de>,
- T: TryFrom<u64> + TryFrom<i64> + FromStr,
- <T as TryFrom<u64>>::Error: Display,
- <T as TryFrom<i64>>::Error: Display,
- <T as FromStr>::Err: Display,
-{
- deserializer.deserialize_any(NumberVisitor {
- marker: PhantomData,
- })
-}
-
-#[derive(Deserialize, Debug)]
-pub struct Struct {
- #[serde(deserialize_with = "deserialize_integer_or_string")]
- pub i: i64,
-}
-
-#[test]
-fn test() {
- let j = r#" {"i":100} "#;
- println!("{:?}", serde_json::from_str::<Struct>(j).unwrap());
-
- let j = r#" {"i":"100"} "#;
- println!("{:?}", serde_json::from_str::<Struct>(j).unwrap());
-}
diff --git a/vendor/serde_json/tests/regression/issue953.rs b/vendor/serde_json/tests/regression/issue953.rs
deleted file mode 100644
index 771aa52..0000000
--- a/vendor/serde_json/tests/regression/issue953.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-use serde_json::Value;
-
-#[test]
-fn test() {
- let x1 = serde_json::from_str::<Value>("18446744073709551615.");
- assert!(x1.is_err());
- let x2 = serde_json::from_str::<Value>("18446744073709551616.");
- assert!(x2.is_err());
-}