unit_testing/
lib.rs
1#![allow(clippy::multiple_crate_versions)]
2pub mod assertions;
3pub mod objects;
4pub mod output;
5pub mod suite;
6pub mod unit;
7
8#[macro_export]
17macro_rules! assert_that {
18 ($title:expr,$description:expr,$time:expr,$callbacks:expr) => {
19 Assert::it($title, $description, $time, $callbacks);
20 };
21}
22
23#[macro_export]
32macro_rules! check_that {
33 ($title:expr,$description:expr,$time:expr,$callbacks:expr) => {
34 Unit::it($title, $description, $time, $callbacks);
35 };
36}
37#[macro_export]
43macro_rules! always_panic {
44 () => {
45 std::panic::set_hook(Box::new(|_| {}));
46 panic!("");
47 };
48}
49#[macro_export]
60macro_rules! run {
61 ($t:expr,$s:expr,$e:expr,$before:ident,$after:ident) => {
62 $before();
63 std::panic::set_hook(Box::new(|_| {
64 println!(
65 "{}\n",
66 format_args!("\t\t{} {}", "*".red().bold(), $e.red().blink().bold())
67 );
68 }));
69 if $t.eq(&false) {
70 panic!("");
71 }
72 println!(
73 "{}\n",
74 format_args!(
75 "\t\t{} {}",
76 "".true_color(55, 190, 176).bold(),
77 $s.true_color(55, 190, 176).bold()
78 )
79 );
80 $after();
81 std::thread::sleep(std::time::Duration::from_millis(50));
82 };
83}
84
85#[macro_export]
98macro_rules! it {
99 ($title:expr,$description:expr,$before_all:ident,$before:ident,$after_all:ident,$after:ident,$main:ident) => {
100 assert!($crate::suite::describe(
101 $title,
102 $description,
103 $after_all,
104 $after,
105 $before_all,
106 $before,
107 $main,
108 )
109 .end()
110 .is_ok());
111 };
112}