]> git.proxmox.com Git - cargo.git/blob - vendor/itoa-0.3.4/tests/test.rs
New upstream version 0.23.0
[cargo.git] / vendor / itoa-0.3.4 / tests / test.rs
1 #![cfg_attr(feature = "i128", feature(i128_type, i128))]
2
3 #![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, string_lit_as_bytes))]
4
5 #![allow(non_snake_case)]
6
7 extern crate itoa;
8
9 macro_rules! test {
10 (
11 $(
12 $(#[$attr:meta])*
13 $name:ident($value:expr, $expected:expr)
14 ),*
15 ) => {
16 $(
17 $(#[$attr])*
18 #[test]
19 fn $name() {
20 let mut buf = [b'\0'; 40];
21 let len = itoa::write(&mut buf[..], $value).unwrap();
22 assert_eq!(&buf[0..len], $expected.as_bytes());
23 }
24 )*
25 }
26 }
27
28 test!{
29 test_u64_0(0u64, "0"),
30 test_u64_half(<u32>::max_value() as u64, "4294967295"),
31 test_u64_max(<u64>::max_value(), "18446744073709551615"),
32 test_i64_min(<i64>::min_value(), "-9223372036854775808"),
33
34 test_i16_0(0i16, "0"),
35 test_i16_min(<i16>::min_value(), "-32768"),
36
37 #[cfg(feature = "i128")]
38 test_u128_0(0u128, "0"),
39 #[cfg(feature = "i128")]
40 test_u128_max(<u128>::max_value(), "340282366920938463463374607431768211455"),
41 #[cfg(feature = "i128")]
42 test_i128_min(<i128>::min_value(), "-170141183460469231731687303715884105728")
43 }