]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/consts/const-endianess.rs
remove useless ident() functions in const tests and replace the useful ones by black_...
[rust.git] / src / test / run-pass / consts / const-endianess.rs
1 // run-pass
2 #![feature(test)]
3
4 extern crate test;
5 use test::black_box as b; // prevent promotion of the argument and const-propagation of the result
6
7 const BE_U32: u32 = 55u32.to_be();
8 const LE_U32: u32 = 55u32.to_le();
9
10 fn main() {
11     assert_eq!(BE_U32, b(55u32).to_be());
12     assert_eq!(LE_U32, b(55u32).to_le());
13
14     #[cfg(not(target_os = "emscripten"))]
15     {
16         const BE_U128: u128 = 999999u128.to_be();
17         const LE_I128: i128 = (-999999i128).to_le();
18         assert_eq!(BE_U128, b(999999u128).to_be());
19         assert_eq!(LE_I128, b(-999999i128).to_le());
20     }
21 }