2019-02-05 12:06:08 -06:00
|
|
|
macro_rules! assert_const {
|
|
|
|
($len:expr) => {
|
|
|
|
assert!($len > 0);
|
|
|
|
debug_assert!($len < 0);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-12-25 16:29:03 -06:00
|
|
|
fn main() {
|
|
|
|
assert!(true);
|
|
|
|
assert!(false);
|
2019-01-09 12:30:47 -06:00
|
|
|
assert!(true, "true message");
|
|
|
|
assert!(false, "false message");
|
|
|
|
|
2019-10-07 13:40:05 -05:00
|
|
|
let msg = "panic message";
|
|
|
|
assert!(false, msg.to_uppercase());
|
|
|
|
|
2019-01-09 12:30:47 -06:00
|
|
|
const B: bool = true;
|
|
|
|
assert!(B);
|
|
|
|
|
|
|
|
const C: bool = false;
|
|
|
|
assert!(C);
|
2019-10-05 09:45:02 -05:00
|
|
|
assert!(C, "C message");
|
2019-02-05 12:06:08 -06:00
|
|
|
|
|
|
|
debug_assert!(true);
|
2019-04-18 04:48:19 -05:00
|
|
|
// Don't lint this, since there is no better way for expressing "Only panic in debug mode".
|
|
|
|
debug_assert!(false); // #3948
|
2019-02-05 12:06:08 -06:00
|
|
|
assert_const!(3);
|
|
|
|
assert_const!(-1);
|
2018-12-25 16:29:03 -06:00
|
|
|
}
|