macro_rules! assert_always {
($condition:expr, $message:expr$(, $details:expr)?) => { ... };
($($rest:tt)*) => { ... };
}Expand description
Assert that condition is true every time this function is called, and that it is
called at least once. The corresponding test property will be viewable in the Antithesis SDK: Always group of your triage report.
§Example
use serde_json::{json};
use antithesis_sdk::{assert_always, random};
const MAX_ALLOWED: u64 = 100;
let actual = random::get_random() % 100u64;
let details = json!({"max_allowed": MAX_ALLOWED, "actual": actual});
antithesis_sdk::assert_always!(actual < MAX_ALLOWED, "Value in range", &details);Ensure that non-const-evaluable messages are rejected.
use serde_json::json;
const MESSAGE: &str = concat!("Value", " in range");
antithesis_sdk::assert_always!(true, MESSAGE, &json!({}));A message computed at runtime is rejected at compile time:
ⓘ
use serde_json::json;
let message = String::from("Value in range");
antithesis_sdk::assert_always!(true, message, &json!({}));ⓘ
use serde_json::json;
antithesis_sdk::assert_always!(true, format!("{}", "Value in range"), &json!({}));