assertify!() { /* proc-macro */ }
👎Deprecated since 0.7.0: use assert2::assert! instead
Expand description
Assert an expression is true or give a useful error when it isn’t.
If the expression contains a comparison, e.g. ==
, then the failure message
will display the value of both sides of the comparison. Note that the
right side will be listed as the “expected” value — think “right” as in
“correct.”
§Examples
§Error for a failed comparison
ⓘ
assertify!(1 + 2 == 0);
Produces:
---- tests::simple_eq stdout ----
thread 'tests::simple_eq' panicked at 'failed: 1 + 2 == 0
actual: 3
expected: == 0
', src/lib.rs:96:9
§Error for other failures
ⓘ
assertify!(false);
Produces:
---- tests::simple_literal stdout ----
thread 'tests::simple_literal' panicked at 'failed: false', src/lib.rs:131:9