stdlib/testView source ↗
test
22 items · generated by scribe fromstdlib/test.fd· synced 2026-11-15
Contents
- TestRunner (struct)
- test_runner_new (function)
- test_begin (function)
- test_pass (function)
- test_fail (function)
- test_summary (function)
- test_all_passed (function)
- test_assert_eq (function)
- test_assert_ne (function)
- test_assert_true (function)
- test_assert_false (function)
- test_assert_approx_eq (function)
- test_assert_gt (function)
- test_assert_lt (function)
- test_assert_in_range (function)
- test_assert_str_eq (function)
- test_assert_empty (function)
- test_assert_len (function)
- test_assert_contains (function)
- test_assert_or_abort (function)
- test_assert_eq_or_abort (function)
- expect_snapshot (function)
TestRunner
Global test counters (managed via a TestRunner struct since Fides has no globals).
pub struct TestRunner {Fields:
| Name | Type |
|---|---|
passed | i64 |
failed | i64 |
current_test | str |
Defined at line 16
test_runner_new
Create a new test runner.
pub fn test_runner_new() -> TestRunner {Returns: TestRunner
Defined at line 23
test_begin
Begin a named test.
pub fn test_begin(runner: & mut TestRunner, name: str) -> void {Parameters:
runner:& mut TestRunnername:str
Returns: void
Defined at line 30
test_pass
End the current test (mark as passed).
pub fn test_pass(runner: & mut TestRunner) -> void {Parameters:
runner:& mut TestRunner
Returns: void
Defined at line 37
test_fail
Mark the current test as failed.
pub fn test_fail(runner: & mut TestRunner, msg: str) -> void {Parameters:
runner:& mut TestRunnermsg:str
Returns: void
Defined at line 42
test_summary
Print test summary.
pub fn test_summary(runner: TestRunner) -> void {Parameters:
runner:TestRunner
Returns: void
Defined at line 49
test_all_passed
Check if all tests passed.
pub fn test_all_passed(runner: TestRunner) -> bool {Parameters:
runner:TestRunner
Returns: bool
Defined at line 67
test_assert_eq
Assert two i64 values are equal. Prints message on failure.
pub fn test_assert_eq(a: i64, b: i64, msg: str) -> bool {Parameters:
a:i64b:i64msg:str
Returns: bool
Defined at line 74
test_assert_ne
Assert two i64 values are NOT equal.
pub fn test_assert_ne(a: i64, b: i64, msg: str) -> bool {Parameters:
a:i64b:i64msg:str
Returns: bool
Defined at line 88
test_assert_true
Assert a condition is true.
pub fn test_assert_true(cond: bool, msg: str) -> bool {Parameters:
cond:boolmsg:str
Returns: bool
Defined at line 100
test_assert_false
Assert a condition is false.
pub fn test_assert_false(cond: bool, msg: str) -> bool {Parameters:
cond:boolmsg:str
Returns: bool
Defined at line 110
test_assert_approx_eq
Assert two f64 values are approximately equal (within epsilon).
pub fn test_assert_approx_eq(a: f64, b: f64, epsilon: f64, msg: str) -> bool {Parameters:
a:f64b:f64epsilon:f64msg:str
Returns: bool
Defined at line 121
test_assert_gt
Assert a value is greater than another.
pub fn test_assert_gt(a: i64, b: i64, msg: str) -> bool {Parameters:
a:i64b:i64msg:str
Returns: bool
Defined at line 140
test_assert_lt
Assert a value is less than another.
pub fn test_assert_lt(a: i64, b: i64, msg: str) -> bool {Parameters:
a:i64b:i64msg:str
Returns: bool
Defined at line 154
test_assert_in_range
Assert a value is in a range [lo, hi].
pub fn test_assert_in_range(value: i64, lo: i64, hi: i64, msg: str) -> bool {Parameters:
value:i64lo:i64hi:i64msg:str
Returns: bool
Defined at line 168
test_assert_str_eq
Assert a string equals another string.
pub fn test_assert_str_eq(a: str, b: str, msg: str) -> bool {Parameters:
a:strb:strmsg:str
Returns: bool
Defined at line 185
test_assert_empty
Assert a Vec is empty.
pub fn test_assert_empty(v: Vec<i64>, msg: str) -> bool {Parameters:
v:Vec<i64>msg:str
Returns: bool
Defined at line 200
test_assert_len
Assert a Vec has a specific length.
pub fn test_assert_len(v: Vec<i64>, expected: i64, msg: str) -> bool {Parameters:
v:Vec<i64>expected:i64msg:str
Returns: bool
Defined at line 212
test_assert_contains
Assert a Vec contains a value.
pub fn test_assert_contains(v: Vec<i64>, value: i64, msg: str) -> bool {Parameters:
v:Vec<i64>value:i64msg:str
Returns: bool
Defined at line 226
test_assert_or_abort
Assert and abort if false.
pub fn test_assert_or_abort(cond: bool, msg: str) -> void {Parameters:
cond:boolmsg:str
Returns: void
Defined at line 240
test_assert_eq_or_abort
Assert equal and abort if not.
pub fn test_assert_eq_or_abort(a: i64, b: i64, msg: str) -> void {Parameters:
a:i64b:i64msg:str
Returns: void
Defined at line 249
expect_snapshot
expect_snapshot(name, value): compares value with the stored snapshot in <name>.snap next to the test that calls it. fid test --update (or FIDES_UPDATE=1) writes the file instead of comparing. A missing file is a failure that says how to create it.
pub fn expect_snapshot(name: str, value: str) -> void {Parameters:
name:strvalue:str
Returns: void
Defined at line 267
Generated by scribe, the Fides documentation generator