From 333762f79e33017f1a1aad922ada6fa93660dfc9 Mon Sep 17 00:00:00 2001 From: Qiushi Pan <17402261+qqhann@users.noreply.github.com> Date: Sat, 19 Mar 2022 20:01:42 +0900 Subject: [PATCH] chore: test large decimal convert --- arms/src/convert/number_base.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arms/src/convert/number_base.rs b/arms/src/convert/number_base.rs index f918645..836c2d0 100644 --- a/arms/src/convert/number_base.rs +++ b/arms/src/convert/number_base.rs @@ -54,4 +54,26 @@ mod tests { let output = super::number_base_convert(16, 10, input).unwrap(); assert_eq!(output, "42"); } + + #[test] + fn very_large_decimal_to_binary() { + let input = "1000000000000000000"; + let output = super::number_base_convert(10, 2, input).unwrap(); + assert_eq!( + output, + "110111100000101101101011001110100111011001000000000000000000" + ); + } + #[test] + fn very_large_decimal_to_octal() { + let input = "1000000000000000000"; + let output = super::number_base_convert(10, 8, input).unwrap(); + assert_eq!(output, "67405553164731000000"); + } + #[test] + fn very_large_decimal_to_hexadecimal() { + let input = "1000000000000000000"; + let output = super::number_base_convert(10, 16, input).unwrap(); + assert_eq!(output, "DE0B6B3A7640000"); + } }