diff options
author | Vincent Breitmoser <look@my.amazin.horse> | 2019-01-16 22:32:22 +0100 |
---|---|---|
committer | Vincent Breitmoser <look@my.amazin.horse> | 2019-01-16 22:32:22 +0100 |
commit | 6ba7135380d747d249da3daeaad03752e081fea1 (patch) | |
tree | 2975002432f47b46de2bea2928661d5dc80f8f7e /src/macros.rs | |
parent | 35019b53f28cb8716ea6826f579afc4f70173818 (diff) |
tests: add "khprintln!" macro to check stdout in tests
Diffstat (limited to 'src/macros.rs')
-rw-r--r-- | src/macros.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/macros.rs b/src/macros.rs new file mode 100644 index 0000000..a393399 --- /dev/null +++ b/src/macros.rs @@ -0,0 +1,32 @@ +#[macro_export] +macro_rules! khprint { + () => (); + ($($arg:tt)*) => ({ + let line = format!($($arg)*); + #[cfg(test)] { + use testutils; + testutils::test_stdout_write(&line); + } + print!("{}", line); + }) +} + +#[macro_export] +macro_rules! khprintln { + () => ({ + #[cfg(test)] { + use testutils; + testutils::test_stdout_write("\n"); + } + println!(); + }); + ($($arg:tt)*) => ({ + let line = format!($($arg)*); + #[cfg(test)] { + use testutils; + testutils::test_stdout_write(&line); + testutils::test_stdout_write("\n"); + } + println!("{}", line); + }) +} |