summary refs log tree commit diff
path: root/src/test/run-pass/enum-discrim-autosizing.rs
blob: ef34115739dd47c7a456ffd11ae86df73d64255c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::mem::size_of;

enum Ei8 {
    Ai8 = -1,
    Bi8 = 0
}

enum Eu8 {
    Au8 = 0,
    Bu8 = 0x80
}

enum Ei16 {
    Ai16 = -1,
    Bi16 = 0x80
}

enum Eu16 {
    Au16 = 0,
    Bu16 = 0x8000
}

enum Ei32 {
    Ai32 = -1,
    Bi32 = 0x8000
}

enum Eu32 {
    Au32 = 0,
    Bu32 = 0x8000_0000
}

enum Ei64 {
    Ai64 = -1,
    Bi64 = 0x8000_0000
}

enum Eu64 {
    Au64 = 0,
    Bu64 = 0x8000_0000_0000_0000
}

pub fn main() {
    assert_eq!(size_of::<Ei8>(), 1);
    assert_eq!(size_of::<Eu8>(), 1);
    assert_eq!(size_of::<Ei16>(), 2);
    assert_eq!(size_of::<Eu16>(), 2);
    assert_eq!(size_of::<Ei32>(), 4);
    assert_eq!(size_of::<Eu32>(), 4);
    assert_eq!(size_of::<Ei64>(), 8);
    assert_eq!(size_of::<Eu64>(), 8);
}