Add some more tests
authorunc0rr
Sat, 13 Oct 2018 17:23:19 +0200
changeset 13883 2bfd7472ef1d
parent 13882 b172a5d40eee
child 13884 fbbb4fcd6a75
Add some more tests
rust/fpnum/src/lib.rs
--- a/rust/fpnum/src/lib.rs	Fri Oct 12 22:18:38 2018 +0200
+++ b/rust/fpnum/src/lib.rs	Sat Oct 13 17:23:19 2018 +0200
@@ -309,13 +309,15 @@
     assert!(z.is_zero());
     assert!(z.is_positive());
     assert!((-z).is_negative);
-    assert_eq!(n - n, z)
+    assert_eq!(n - n, z);
+    assert_eq!(-n + n, z);
 }
 
 #[test]
 fn arith() {
     let n1_5 = FPNum::new(3, 2);
     let n2_25 = FPNum::new(9, 4);
+    let n_0_15 = FPNum::new(-15, 100);
 
     assert_eq!(n1_5 + n1_5, FPNum::from(3));
     assert_eq!(-n1_5 - n1_5, FPNum::from(-3));
@@ -325,6 +327,9 @@
     assert_eq!(n1_5 * -n1_5, -n2_25);
     assert_eq!(-n1_5 * n1_5, -n2_25);
 
+    assert_eq!(-n2_25 / -n1_5, n1_5);
+    assert_eq!(n1_5 / -10, n_0_15);
+
     assert_eq!(n1_5.sqr(), n2_25);
     assert_eq!((-n1_5).sqr(), n2_25);