interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / itoa / tests / test.rs

45 lines · 1277 bytes Raw Blame History
1#![allow(non_snake_case)]
2
3macro_rules! test {
4 ($($name:ident($value:expr, $expected:expr))*) => {
5 $(
6 #[test]
7 fn $name() {
8 let mut buffer = itoa::Buffer::new();
9 let s = buffer.format($value);
10 assert_eq!(s, $expected);
11 }
12 )*
13 }
14}
15
16test! {
17 test_u64_0(0u64, "0")
18 test_u64_half(u64::from(u32::MAX), "4294967295")
19 test_u64_max(u64::MAX, "18446744073709551615")
20 test_i64_min(i64::MIN, "-9223372036854775808")
21
22 test_i16_0(0i16, "0")
23 test_i16_min(i16::MIN, "-32768")
24
25 test_u128_0(0u128, "0")
26 test_u128_max(u128::MAX, "340282366920938463463374607431768211455")
27 test_i128_min(i128::MIN, "-170141183460469231731687303715884105728")
28 test_i128_max(i128::MAX, "170141183460469231731687303715884105727")
29}
30
31#[test]
32fn test_max_str_len() {
33 use itoa::Integer as _;
34
35 assert_eq!(i8::MAX_STR_LEN, 4);
36 assert_eq!(u8::MAX_STR_LEN, 3);
37 assert_eq!(i16::MAX_STR_LEN, 6);
38 assert_eq!(u16::MAX_STR_LEN, 5);
39 assert_eq!(i32::MAX_STR_LEN, 11);
40 assert_eq!(u32::MAX_STR_LEN, 10);
41 assert_eq!(i64::MAX_STR_LEN, 20);
42 assert_eq!(u64::MAX_STR_LEN, 20);
43 assert_eq!(i128::MAX_STR_LEN, 40);
44 assert_eq!(u128::MAX_STR_LEN, 39);
45}