Skip to content

Commit

Permalink
Test the CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
orecham committed Sep 11, 2024
1 parent e553c74 commit e3b1b25
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 121 deletions.
37 changes: 37 additions & 0 deletions iceoryx2-bb/testing/src/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@ macro_rules! assert_that {
}
}
};
($lhs:expr, contains_match |$element:ident| $predicate:expr) => {
{
let mut does_contain = false;
for $element in &$lhs {
if $predicate {
does_contain = true;
break;
}
}
if !does_contain {
assert_that!(message_contains_match $lhs, core::stringify!($predicate));
}
}
};
($lhs:expr, not_contains_match |$element:ident| $predicate:expr) => {
{
let mut does_contain = false;
for $element in &$lhs {
if $predicate {
does_contain = true;
break;
}
}
if does_contain {
assert_that!(message_contains_match $lhs, core::stringify!($predicate));
}
}
};
($lhs:expr, time_at_least $rhs:expr) => {
{
let lval = $lhs.as_secs_f32();
Expand Down Expand Up @@ -237,6 +265,15 @@ macro_rules! assert_that {
assert_that![color_end]
);
};
[message_contains_match $lhs:expr, $predicate:expr] => {
core::panic!(
"assertion failed: {}expr: {} contains no element matching predicate: {}{}",
assert_that![color_start],
core::stringify!($lhs),
$predicate,
assert_that![color_end]
);
};
[message_property $lhs:expr, $lval:expr, $property:expr, $rhs:expr] => {
core::panic!(
"assertion failed: {}expr: {}.{} == {}; value: {} == {}{}",
Expand Down
6 changes: 5 additions & 1 deletion iceoryx2-cli/iox2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ better-panic = { workspace = true }
colored = { workspace = true }
clap = { workspace = true }
human-panic = { workspace = true }
thiserror = { workspace = true }
cargo_metadata = { version = "0.18.1" }

[dev-dependencies]
iceoryx2-bb-testing = { workspace = true }
tempfile = { version = "3.12.0" }
Loading

0 comments on commit e3b1b25

Please sign in to comment.