extern crate ntest_test_cases;
#[doc(inline)]
pub use ntest_test_cases::test_case;
#[macro_export]
macro_rules! assert_true {
($x:expr) => ({
if !$x {
panic!("assertion failed: Expected 'true', but was 'false'");
}
});
($x:expr,) => ({
assert_true!($x);
});
}
#[macro_export]
macro_rules! assert_false {
($x:expr) => ({
if $x {
panic!("assertion failed: Expected 'false', but was 'true'");
}
});
($x:expr,) => ({
assert_false!($x);
});
}
#[macro_export]
macro_rules! assert_panics {
($x:block) => ({
let result = std::panic::catch_unwind(||$x);
if !result.is_err(){
panic!("assertion failed: code in block did not panic");
}
});
($x:block,) => ({
assert_panics!($x);
});
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn assert_true() {
assert_true!(true);
}
#[test]
#[should_panic]
fn assert_true_fails() {
assert_true!(false);
}
#[test]
fn assert_true_trailing_comma() {
assert_true!(true,);
}
#[test]
fn assert_false() {
assert_false!(false);
}
#[test]
#[should_panic]
fn assert_false_fails() {
assert_false!(true);
}
#[test]
fn assert_false_trailing_comma() {
assert_false!(false,);
}
#[test]
fn assert_panics() {
assert_panics!({panic!("I am panicing!")},);
}
#[test]
#[should_panic]
fn assert_panics_fails() {
assert_panics!({println!("I am not panicing!")},);
}
#[test]
fn assert_panics_trailing_comma() {
assert_panics!({panic!("I am panicing!")},);
}
}