]> git.lizzy.rs Git - rust.git/commitdiff
[Tests] added float tests
authorDavid Rajchenbach-Teller <dteller@mozilla.com>
Wed, 12 Oct 2011 08:25:58 +0000 (10:25 +0200)
committerDavid Rajchenbach-Teller <dteller@mozilla.com>
Wed, 12 Oct 2011 08:56:05 +0000 (10:56 +0200)
src/test/stdtest/float.rs [new file with mode: 0644]
src/test/stdtest/stdtest.rc

diff --git a/src/test/stdtest/float.rs b/src/test/stdtest/float.rs
new file mode 100644 (file)
index 0000000..b77d83e
--- /dev/null
@@ -0,0 +1,19 @@
+use std;
+import std::float;
+
+#[test]
+fn test_from_str() {
+   assert ( float::from_str("3.14") == 3.14 );
+   assert ( float::from_str("+3.14") == 3.14 );
+   assert ( float::from_str("-3.14") == -3.14 );
+   assert ( float::from_str("2.5E10") == 25000000000. );
+   assert ( float::from_str("2.5e10") == 25000000000. );
+   assert ( float::from_str("25000000000.E-10") == 2.5 );
+   assert ( float::from_str("") == 0. );
+   assert ( float::from_str("   ") == 0. );
+   assert ( float::from_str(".") == 0. );
+   assert ( float::from_str("5.") == 5. );
+   assert ( float::from_str(".5") == 0.5 );
+   assert ( float::from_str("0.5") == 0.5 );
+
+}
index b94f18f77f4af14fd38354bdf47fa780df1ae961..46292756a47e74a625286a07aa926078aac4efe1 100644 (file)
@@ -29,6 +29,7 @@ mod sys;
 mod task;
 mod test;
 mod uint;
+mod float;
 
 // Local Variables:
 // mode: rust