]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/packed-tuple-struct-size.rs
rustdoc: Replace no-pretty-expanded with pretty-expanded
[rust.git] / src / test / run-pass / packed-tuple-struct-size.rs
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
11
12 // pretty-expanded FIXME #23616
13
14 use std::mem;
15
16 #[repr(packed)]
17 struct S4(u8,[u8;  3]);
18
19 #[repr(packed)]
20 struct S5(u8, u32);
21
22 #[repr(packed)]
23 struct S13(i64, f32, u8);
24
25 enum Foo {
26     Bar = 1,
27     Baz = 2
28 }
29
30 #[repr(packed)]
31 struct S3_Foo(u8, u16, Foo);
32
33 #[repr(packed)]
34 struct S7_Option(f32, u8, u16, Option<Box<f64>>);
35
36 pub fn main() {
37     assert_eq!(mem::size_of::<S4>(), 4);
38
39     assert_eq!(mem::size_of::<S5>(), 5);
40
41     assert_eq!(mem::size_of::<S13>(), 13);
42
43     assert_eq!(mem::size_of::<S3_Foo>(),
44                3 + mem::size_of::<Foo>());
45
46     assert_eq!(mem::size_of::<S7_Option>(),
47               7 + mem::size_of::<Option<Box<f64>>>());
48 }