diff options
| author | olivia <olivia@fastmail.com> | 2018-05-16 15:23:14 +0200 |
|---|---|---|
| committer | olivia <olivia@fastmail.com> | 2018-05-16 15:23:14 +0200 |
| commit | d9946a91d429b2de2d0e21a2f346821f29c6ec5a (patch) | |
| tree | af25ff7f76a52254ccb9adb49bde7dc150602c20 /src/macros.rs | |
| parent | 8ea1b17fd9505da92a7233d8bfd6d5f1c3d9a93e (diff) | |
make the example work
Diffstat (limited to 'src/macros.rs')
| -rw-r--r-- | src/macros.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..5c80b84 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,31 @@ +#[macro_export] +macro_rules! verify { + ($left:expr, $right:expr, $str:expr) => { + use ansi_term::Color::{Green, Red}; + + if $left == $right { + println!("{} {}", Green.bold().paint("PASS"), $str); + } else { + println!("{} {}", Red.bold().paint("FAIL"), $str); + println!("\tYou submitted {}, but that's not correct!", $left); + println!("\tPlease correct your code to make this test pass!"); + } + }; +} + +#[macro_export] +macro_rules! verify_easy { + ($str:expr, $left:expr, $right:expr) => { + use ansi_term::Color::{Green, Red}; + + if $left == $right { + println!("{} {}", Green.bold().paint("PASS"), $str); + } else { + println!("{} {}", Red.bold().paint("FAIL"), $str); + println!("\tExpected: {}", $right); + println!("\tGot: {}", $left); + println!("\tPlease correct your code to make this test pass!"); + } + }; +} + |
