From d5d7c855b0c8f4fa1db4e9dee6b22dc873ca25e8 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Sun, 17 Jan 2016 12:13:45 -0800 Subject: [PATCH] Add tests for UpperHex and LowerHex --- src/bigint.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/bigint.rs b/src/bigint.rs index 4acc2ac..6255070 100644 --- a/src/bigint.rs +++ b/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 {