diff options
Diffstat (limited to 'src/test_macros.rs')
| -rw-r--r-- | src/test_macros.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/test_macros.rs b/src/test_macros.rs index 9f3ff2b..e1998cd 100644 --- a/src/test_macros.rs +++ b/src/test_macros.rs @@ -1,4 +1,17 @@ #[macro_export] +macro_rules! test { + (fn $name:ident() $body:block) => { + #[test] + fn $name() -> Result<(), Box<dyn std::error::Error>> { + (|| -> Result<(), Box<dyn std::error::Error>> { + $body; + Ok(()) + })() + } + }; +} + +#[macro_export] macro_rules! assert_error { ($result:expr, $pattern:pat => $body:block) => { match $result { @@ -12,9 +25,9 @@ macro_rules! assert_error { } #[macro_export] -macro_rules! assert_file_not_found { +macro_rules! assert_config_file_not_found { ($result:expr, $expected_path:expr) => { - assert_error!($result, AppError::FileNotFound(path) => { + assert_error!($result, AppError::ConfigFileNotFound(path) => { assert_eq!(path, $expected_path, "Expected file not found for path {:?}, but got path {:?}", $expected_path, path); |
