Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Adds test cases for f32 representations (inf and nan)
Browse files Browse the repository at this point in the history
  • Loading branch information
john.burkhardt committed Sep 10, 2021
1 parent c420357 commit 7d07fe6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_serde.rs
Expand Up @@ -143,6 +143,28 @@ fn test_float32() {
25.6
"};
test_serde(&thing, yaml);

let thing = f32::INFINITY;
let yaml = indoc! {"
---
.inf
"};
test_serde(&thing, yaml);

let thing = f32::NEG_INFINITY;
let yaml = indoc! {"
---
-.inf
"};
test_serde(&thing, yaml);

let single_float: f32 = serde_yaml::from_str(indoc! {"
---
.nan
"})
.unwrap();
assert!(single_float.is_nan());

}

#[test]
Expand Down

0 comments on commit 7d07fe6

Please sign in to comment.