]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // run-pass |
2 | ||
b7449926 XL |
3 | const REVERSE: u32 = 0x12345678_u32.reverse_bits(); |
4 | const FROM_BE_BYTES: i32 = i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]); | |
5 | const FROM_LE_BYTES: i32 = i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]); | |
6 | const FROM_NE_BYTES: i32 = i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])); | |
7 | const TO_BE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_be_bytes(); | |
8 | const TO_LE_BYTES: [u8; 4] = 0x12_34_56_78_i32.to_le_bytes(); | |
f035d41b | 9 | const TO_NE_BYTES: [u8; 4] = i32::MIN.to_be().to_ne_bytes(); |
b7449926 | 10 | |
b7449926 | 11 | fn main() { |
dc9dc135 XL |
12 | assert_eq!(REVERSE, 0x1e6a2c48); |
13 | assert_eq!(FROM_BE_BYTES, 0x12_34_56_78); | |
14 | assert_eq!(FROM_LE_BYTES, 0x78_56_34_12); | |
f035d41b | 15 | assert_eq!(FROM_NE_BYTES, i32::MIN); |
dc9dc135 XL |
16 | assert_eq!(TO_BE_BYTES, [0x12, 0x34, 0x56, 0x78]); |
17 | assert_eq!(TO_LE_BYTES, [0x78, 0x56, 0x34, 0x12]); | |
18 | assert_eq!(TO_NE_BYTES, [0x80, 0, 0, 0]); | |
b7449926 | 19 | } |