Skip to content

Commit 75bda42

Browse files
author
David Rajchenbach-Teller
committed
[Tests] added float tests
1 parent 8c9dd54 commit 75bda42

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/test/stdtest/float.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
}

src/test/stdtest/stdtest.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ mod sys;
2929
mod task;
3030
mod test;
3131
mod uint;
32+
mod float;
3233

3334
// Local Variables:
3435
// mode: rust

0 commit comments

Comments
 (0)