ade_common/
lib.rs

1pub const INVALID_KEY_SEQUENCE: &str =
2    "Invalid key sequence: keys must be sequential integers from 0 to n-1";
3
4#[cfg(feature = "test-helpers")]
5#[macro_export]
6macro_rules! assert_panics_with {
7    ($expr:expr, $expected:expr $(,)?) => {{
8        let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| $expr));
9        match res {
10            Ok(_) => panic!(
11                "expected panic with {:?}, but code did not panic",
12                $expected
13            ),
14            Err(err) => {
15                let msg = err
16                    .downcast_ref::<String>()
17                    .map(String::as_str)
18                    .or_else(|| err.downcast_ref::<&'static str>().copied());
19                assert_eq!(msg, Some($expected), "panic message mismatch");
20            }
21        }
22    }};
23}