]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/type-sizes.rs
Imported Upstream version 0.6
[rustc.git] / src / test / run-pass / type-sizes.rs
1 // Copyright 2012 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 // xfail-test
12 use sys::rustrt::size_of;
13 extern mod std;
14
15 pub fn main() {
16 assert!((size_of::<u8>() == 1 as uint));
17 assert!((size_of::<u32>() == 4 as uint));
18 assert!((size_of::<char>() == 4 as uint));
19 assert!((size_of::<i8>() == 1 as uint));
20 assert!((size_of::<i32>() == 4 as uint));
21 assert!((size_of::<{a: u8, b: i8}>() == 2 as uint));
22 assert!((size_of::<{a: u8, b: i8, c: u8}>() == 3 as uint));
23 // Alignment causes padding before the char and the u32.
24
25 assert!(size_of::<{a: u8, b: i8, c: {u: char, v: u8}, d: u32}>() ==
26 16 as uint);
27 assert!((size_of::<int>() == size_of::<uint>()));
28 assert!((size_of::<{a: int, b: ()}>() == size_of::<int>()));
29 assert!((size_of::<{a: int, b: (), c: ()}>() == size_of::<int>()));
30 assert!((size_of::<int>() == size_of::<{x: int}>()));
31 }