]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_data_structures/src/base_n/tests.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / compiler / rustc_data_structures / src / base_n / tests.rs
1 use super::*;
2
3 #[test]
4 fn test_encode() {
5 fn test(n: u128, base: usize) {
6 assert_eq!(Ok(n), u128::from_str_radix(&encode(n, base), base as u32));
7 }
8
9 for base in 2..37 {
10 test(0, base);
11 test(1, base);
12 test(35, base);
13 test(36, base);
14 test(37, base);
15 test(u64::MAX as u128, base);
16 test(u128::MAX, base);
17
18 const N: u128 = if cfg!(miri) { 10 } else { 1000 };
19
20 for i in 0..N {
21 test(i * 983, base);
22 }
23 }
24 }