]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
54a0048b | 11 | #![feature(stmt_expr_attributes)] |
c34b1796 | 12 | |
1a4d82fc JJ |
13 | use std::mem::size_of; |
14 | ||
15 | enum Ei8 { | |
16 | Ai8 = -1, | |
17 | Bi8 = 0 | |
18 | } | |
19 | ||
20 | enum Eu8 { | |
21 | Au8 = 0, | |
22 | Bu8 = 0x80 | |
23 | } | |
24 | ||
25 | enum Ei16 { | |
26 | Ai16 = -1, | |
27 | Bi16 = 0x80 | |
28 | } | |
29 | ||
30 | enum Eu16 { | |
31 | Au16 = 0, | |
32 | Bu16 = 0x8000 | |
33 | } | |
34 | ||
35 | enum Ei32 { | |
36 | Ai32 = -1, | |
37 | Bi32 = 0x8000 | |
38 | } | |
39 | ||
40 | enum Eu32 { | |
41 | Au32 = 0, | |
42 | Bu32 = 0x8000_0000 | |
43 | } | |
44 | ||
45 | enum Ei64 { | |
46 | Ai64 = -1, | |
47 | Bi64 = 0x8000_0000 | |
48 | } | |
49 | ||
1a4d82fc JJ |
50 | pub fn main() { |
51 | assert_eq!(size_of::<Ei8>(), 1); | |
52 | assert_eq!(size_of::<Eu8>(), 1); | |
53 | assert_eq!(size_of::<Ei16>(), 2); | |
54 | assert_eq!(size_of::<Eu16>(), 2); | |
55 | assert_eq!(size_of::<Ei32>(), 4); | |
56 | assert_eq!(size_of::<Eu32>(), 4); | |
54a0048b | 57 | #[cfg(target_pointer_width = "64")] |
1a4d82fc | 58 | assert_eq!(size_of::<Ei64>(), 8); |
54a0048b SL |
59 | #[cfg(target_pointer_width = "32")] |
60 | assert_eq!(size_of::<Ei64>(), 4); | |
1a4d82fc | 61 | } |