Browse Source

Add tests for UpperHex and LowerHex

Colin Davidson 9 years ago
parent
commit
d5d7c855b0
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/bigint.rs

+ 18 - 0
src/bigint.rs

@@ -3723,6 +3723,24 @@ mod biguint_tests {
         }
     }
 
+    #[test]
+    fn test_upper_hex() {
+        let a = BigUint::parse_bytes(b"A", 16).unwrap();
+        let hello = BigUint::parse_bytes("22405534230753963835153736737".as_bytes(), 10).unwrap();
+
+        assert_eq!(format!("{:x}", a), "a");
+        assert_eq!(format!("{:x}", hello), "48656c6c6f20776f726c6421");
+    }
+
+    #[test]
+    fn test_lower_hex() {
+        let a = BigUint::parse_bytes(b"A", 16).unwrap();
+        let hello = BigUint::parse_bytes("22405534230753963835153736737".as_bytes(), 10).unwrap();
+
+        assert_eq!(format!("{:X}", a), "A");
+        assert_eq!(format!("{:X}", hello), "48656C6C6F20776F726C6421");
+    }
+
     #[test]
     fn test_factor() {
         fn factor(n: usize) -> BigUint {