]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_data_structures/src/base_n/tests.rs
Rollup merge of #94186 - ehuss:pin-stable-1.61, r=m-ou-se
[rust.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         for i in 0..1_000 {
19             test(i * 983, base);
20         }
21     }
22 }