]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/enum-discrim-autosizing.rs
New upstream version 1.13.0+dfsg1
[rustc.git] / src / test / run-pass / enum-discrim-autosizing.rs
CommitLineData
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
11use std::mem::size_of;
12
13enum Ei8 {
14 Ai8 = -1,
15 Bi8 = 0
16}
17
18enum Eu8 {
19 Au8 = 0,
20 Bu8 = 0x80
21}
22
23enum Ei16 {
24 Ai16 = -1,
25 Bi16 = 0x80
26}
27
28enum Eu16 {
29 Au16 = 0,
30 Bu16 = 0x8000
31}
32
33enum Ei32 {
34 Ai32 = -1,
35 Bi32 = 0x8000
36}
37
38enum Eu32 {
39 Au32 = 0,
40 Bu32 = 0x8000_0000
41}
42
43enum Ei64 {
44 Ai64 = -1,
45 Bi64 = 0x8000_0000
46}
47
1a4d82fc
JJ
48pub fn main() {
49 assert_eq!(size_of::<Ei8>(), 1);
50 assert_eq!(size_of::<Eu8>(), 1);
51 assert_eq!(size_of::<Ei16>(), 2);
52 assert_eq!(size_of::<Eu16>(), 2);
53 assert_eq!(size_of::<Ei32>(), 4);
54 assert_eq!(size_of::<Eu32>(), 4);
54a0048b 55 #[cfg(target_pointer_width = "64")]
1a4d82fc 56 assert_eq!(size_of::<Ei64>(), 8);
54a0048b
SL
57 #[cfg(target_pointer_width = "32")]
58 assert_eq!(size_of::<Ei64>(), 4);
1a4d82fc 59}