]>
Commit | Line | Data |
---|---|---|
b7449926 | 1 | // run-pass |
1a4d82fc JJ |
2 | use std::mem::size_of; |
3 | ||
85aaf69f | 4 | #[derive(PartialEq, Debug)] |
1a4d82fc JJ |
5 | enum Either<T, U> { Left(T), Right(U) } |
6 | ||
7 | macro_rules! check { | |
8 | ($t:ty, $sz:expr, $($e:expr, $s:expr),*) => {{ | |
9 | assert_eq!(size_of::<$t>(), $sz); | |
10 | $({ | |
11 | static S: $t = $e; | |
12 | let v: $t = $e; | |
13 | assert_eq!(S, v); | |
85aaf69f SL |
14 | assert_eq!(format!("{:?}", v), $s); |
15 | assert_eq!(format!("{:?}", S), $s); | |
1a4d82fc JJ |
16 | });* |
17 | }} | |
18 | } | |
19 | ||
20 | pub fn main() { | |
21 | check!(Option<u8>, 2, | |
22 | None, "None", | |
c34b1796 | 23 | Some(129), "Some(129)"); |
1a4d82fc JJ |
24 | check!(Option<i16>, 4, |
25 | None, "None", | |
c34b1796 | 26 | Some(-20000), "Some(-20000)"); |
1a4d82fc | 27 | check!(Either<u8, i8>, 2, |
c34b1796 AL |
28 | Either::Left(132), "Left(132)", |
29 | Either::Right(-32), "Right(-32)"); | |
1a4d82fc | 30 | check!(Either<u8, i16>, 4, |
c34b1796 AL |
31 | Either::Left(132), "Left(132)", |
32 | Either::Right(-20000), "Right(-20000)"); | |
1a4d82fc | 33 | } |