File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 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;
2929mod task;
3030mod test;
3131mod uint;
32+ mod float;
3233
3334// Local Variables:
3435// mode: rust
You can’t perform that action at this time.
0 commit comments