File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -82,8 +82,6 @@ fn test_float() {
82
82
check_fmt ( "% 7.4E" , -120.3 ) ;
83
83
check_fmt ( "%-10F" , f64:: INFINITY ) ;
84
84
check_fmt ( "%+010F" , f64:: INFINITY ) ;
85
- check_fmt ( "% f" , f64:: NAN ) ;
86
- check_fmt ( "%+f" , f64:: NAN ) ;
87
85
check_fmt ( "%.1f" , 999.99 ) ;
88
86
check_fmt ( "%.1f" , 9.99 ) ;
89
87
check_fmt ( "%.1e" , 9.99 ) ;
@@ -99,6 +97,15 @@ fn test_float() {
99
97
check_fmt ( "%.1f" , 2.599 ) ;
100
98
check_fmt ( "%.1e" , 2.599 ) ;
101
99
check_fmt ( "%.1g" , 2.599 ) ;
100
+
101
+ // MacOS libc behaves differently from glibc for nan. glibc is the reference implementation.
102
+ if cfg ! ( target_env = "gnu" ) {
103
+ check_fmt ( "% f" , f64:: NAN ) ;
104
+ check_fmt ( "%+f" , f64:: NAN ) ;
105
+ } else {
106
+ assert_eq ! ( sprintf!( "% f" , f64 :: NAN ) . unwrap( ) , " nan" ) ;
107
+ assert_eq ! ( sprintf!( "%+f" , f64 :: NAN ) . unwrap( ) , "+nan" ) ;
108
+ }
102
109
}
103
110
104
111
#[ test]
You can’t perform that action at this time.
0 commit comments