1
use ron::{
2
    de::from_str,
3
    ser::{to_string, to_string_pretty, PrettyConfig},
4
};
5

            
6
#[test]
7
4
fn test_inf_and_nan() {
8
4
    assert_eq!(from_str("inf"), Ok(std::f64::INFINITY));
9
4
    assert_eq!(from_str("-inf"), Ok(std::f64::NEG_INFINITY));
10
4
    assert_eq!(from_str::<f64>("NaN").map(|n| n.is_nan()), Ok(true))
11
4
}
12

            
13
#[test]
14
4
fn decimal_floats() {
15
4
    let non_pretty = to_string(&1.0).unwrap();
16
4
    assert_eq!(non_pretty, "1.0");
17

            
18
4
    let with_pretty = to_string_pretty(&1.0, PrettyConfig::new()).unwrap();
19
4
    assert_eq!(with_pretty, "1.0");
20

            
21
4
    let tiny_pretty = to_string_pretty(&0.00000000000000005, PrettyConfig::new()).unwrap();
22
4
    assert_eq!(tiny_pretty, "0.00000000000000005");
23
4
}