@@ -2,13 +2,51 @@ use super::*;
2
2
3
3
#[ test]
4
4
fn test_format_with_underscores ( ) {
5
- assert_eq ! ( "0" , format_with_underscores( 0 ) ) ;
6
- assert_eq ! ( "1" , format_with_underscores( 1 ) ) ;
7
- assert_eq ! ( "99" , format_with_underscores( 99 ) ) ;
8
- assert_eq ! ( "345" , format_with_underscores( 345 ) ) ;
9
- assert_eq ! ( "1_000" , format_with_underscores( 1_000 ) ) ;
10
- assert_eq ! ( "12_001" , format_with_underscores( 12_001 ) ) ;
11
- assert_eq ! ( "999_999" , format_with_underscores( 999_999 ) ) ;
12
- assert_eq ! ( "1_000_000" , format_with_underscores( 1_000_000 ) ) ;
13
- assert_eq ! ( "12_345_678" , format_with_underscores( 12_345_678 ) ) ;
5
+ assert_eq ! ( "" , format_with_underscores( "" . to_string( ) ) ) ;
6
+ assert_eq ! ( "0" , format_with_underscores( "0" . to_string( ) ) ) ;
7
+ assert_eq ! ( "12_345.67e14" , format_with_underscores( "12345.67e14" . to_string( ) ) ) ;
8
+ assert_eq ! ( "-1_234.5678e10" , format_with_underscores( "-1234.5678e10" . to_string( ) ) ) ;
9
+ assert_eq ! ( "------" , format_with_underscores( "------" . to_string( ) ) ) ;
10
+ assert_eq ! ( "abcdefgh" , format_with_underscores( "abcdefgh" . to_string( ) ) ) ;
11
+ assert_eq ! ( "-1b" , format_with_underscores( "-1b" . to_string( ) ) ) ;
12
+ assert_eq ! ( "-3_456xyz" , format_with_underscores( "-3456xyz" . to_string( ) ) ) ;
13
+ }
14
+
15
+ #[ test]
16
+ fn test_usize_with_underscores ( ) {
17
+ assert_eq ! ( "0" , usize_with_underscores( 0 ) ) ;
18
+ assert_eq ! ( "1" , usize_with_underscores( 1 ) ) ;
19
+ assert_eq ! ( "99" , usize_with_underscores( 99 ) ) ;
20
+ assert_eq ! ( "345" , usize_with_underscores( 345 ) ) ;
21
+ assert_eq ! ( "1_000" , usize_with_underscores( 1_000 ) ) ;
22
+ assert_eq ! ( "12_001" , usize_with_underscores( 12_001 ) ) ;
23
+ assert_eq ! ( "999_999" , usize_with_underscores( 999_999 ) ) ;
24
+ assert_eq ! ( "1_000_000" , usize_with_underscores( 1_000_000 ) ) ;
25
+ assert_eq ! ( "12_345_678" , usize_with_underscores( 12_345_678 ) ) ;
26
+ }
27
+
28
+ #[ test]
29
+ fn test_isize_with_underscores ( ) {
30
+ assert_eq ! ( "0" , isize_with_underscores( 0 ) ) ;
31
+ assert_eq ! ( "-1" , isize_with_underscores( -1 ) ) ;
32
+ assert_eq ! ( "99" , isize_with_underscores( 99 ) ) ;
33
+ assert_eq ! ( "345" , isize_with_underscores( 345 ) ) ;
34
+ assert_eq ! ( "-1_000" , isize_with_underscores( -1_000 ) ) ;
35
+ assert_eq ! ( "12_001" , isize_with_underscores( 12_001 ) ) ;
36
+ assert_eq ! ( "-999_999" , isize_with_underscores( -999_999 ) ) ;
37
+ assert_eq ! ( "1_000_000" , isize_with_underscores( 1_000_000 ) ) ;
38
+ assert_eq ! ( "-12_345_678" , isize_with_underscores( -12_345_678 ) ) ;
39
+ }
40
+
41
+ #[ test]
42
+ fn test_f64p1_with_underscores ( ) {
43
+ assert_eq ! ( "0.0" , f64p1_with_underscores( 0f64 ) ) ;
44
+ assert_eq ! ( "0.0" , f64p1_with_underscores( 0.00000001 ) ) ;
45
+ assert_eq ! ( "-0.0" , f64p1_with_underscores( -0.00000001 ) ) ;
46
+ assert_eq ! ( "1.0" , f64p1_with_underscores( 0.9999999 ) ) ;
47
+ assert_eq ! ( "-1.0" , f64p1_with_underscores( -0.9999999 ) ) ;
48
+ assert_eq ! ( "345.5" , f64p1_with_underscores( 345.4999999 ) ) ;
49
+ assert_eq ! ( "-100_000.0" , f64p1_with_underscores( -100_000f64 ) ) ;
50
+ assert_eq ! ( "123_456_789.1" , f64p1_with_underscores( 123456789.123456789 ) ) ;
51
+ assert_eq ! ( "-123_456_789.1" , f64p1_with_underscores( -123456789.123456789 ) ) ;
14
52
}
0 commit comments