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

Commit 7d07fe6

Browse files
author
john.burkhardt
committed
Adds test cases for f32 representations (inf and nan)
1 parent c420357 commit 7d07fe6

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎tests/test_serde.rs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,28 @@ fn test_float32() {
143143
25.6
144144
"};
145145
test_serde(&thing, yaml);
146+
147+
let thing = f32::INFINITY;
148+
let yaml = indoc! {"
149+
---
150+
.inf
151+
"};
152+
test_serde(&thing, yaml);
153+
154+
let thing = f32::NEG_INFINITY;
155+
let yaml = indoc! {"
156+
---
157+
-.inf
158+
"};
159+
test_serde(&thing, yaml);
160+
161+
let single_float: f32 = serde_yaml::from_str(indoc! {"
162+
---
163+
.nan
164+
"})
165+
.unwrap();
166+
assert!(single_float.is_nan());
167+
146168
}
147169

148170
#[test]

0 commit comments

Comments
 (0)