Skip to content

Commit

Permalink
Additional serde test for arbitrary precision (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
paupino committed Feb 20, 2022
1 parent 24bb42a commit 34060a2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,19 @@ mod test {
assert_eq!(&serde_json::to_string(&value).unwrap(), r#"{"value":123.400}"#);
}

#[test]
#[cfg(feature = "serde-with-arbitrary-precision")]
fn with_arbitrary_precision_from_string() {
#[derive(Serialize, Deserialize)]
pub struct ArbitraryExample {
#[serde(with = "crate::serde::arbitrary_precision")]
value: Decimal,
}

let value: ArbitraryExample = serde_json::from_str(r#"{"value":"1.1234127836128763"}"#).unwrap();
assert_eq!(value.value.to_string(), "1.1234127836128763");
}

#[test]
#[cfg(feature = "serde-with-float")]
fn with_float() {
Expand Down

0 comments on commit 34060a2

Please sign in to comment.