File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std;
2
+ import std:: float;
3
+
4
+ #[ test]
5
+ fn test_from_str ( ) {
6
+ assert ( float:: from_str ( "3.14" ) == 3.14 ) ;
7
+ assert ( float:: from_str ( "+3.14" ) == 3.14 ) ;
8
+ assert ( float:: from_str ( "-3.14" ) == -3.14 ) ;
9
+ assert ( float:: from_str ( "2.5E10" ) == 25000000000. ) ;
10
+ assert ( float:: from_str ( "2.5e10" ) == 25000000000. ) ;
11
+ assert ( float:: from_str ( "25000000000.E-10" ) == 2.5 ) ;
12
+ assert ( float:: from_str ( "" ) == 0. ) ;
13
+ assert ( float:: from_str ( " " ) == 0. ) ;
14
+ assert ( float:: from_str ( "." ) == 0. ) ;
15
+ assert ( float:: from_str ( "5." ) == 5. ) ;
16
+ assert ( float:: from_str ( ".5" ) == 0.5 ) ;
17
+ assert ( float:: from_str ( "0.5" ) == 0.5 ) ;
18
+
19
+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ mod sys;
29
29
mod task;
30
30
mod test;
31
31
mod uint;
32
+ mod float;
32
33
33
34
// Local Variables:
34
35
// mode: rust
You can’t perform that action at this time.
0 commit comments