Skip to main content

assert_always_or_unreachable

Macro assert_always_or_unreachable 

Source
macro_rules! assert_always_or_unreachable {
    ($condition:expr, $message:expr$(, $details:expr)?) => { ... };
    ($($rest:tt)*) => { ... };
}
Expand description

Assert that condition is true every time this function is called. The corresponding test property will pass even if the assertion is never encountered. This test property will be viewable in the Antithesis SDK: Always group of your triage report.

ยงExample

use serde::Serialize;
use antithesis_sdk::{assert_always_or_unreachable, random};

// Only serialized when the assertion emits; see assert_always.
#[derive(Serialize)]
struct Details { max_allowed: u64, actual: u64 }

const MAX_ALLOWED: u64 = 100;
let actual = random::get_random() % 100u64;
let details = Details { max_allowed: MAX_ALLOWED, actual };
antithesis_sdk::assert_always_or_unreachable!(actual < MAX_ALLOWED, "Value in range", &details);