Skip to main content

Crate test_helpers

Crate test_helpers 

Source
Expand description

Test helpers for Rust.

test_help-rs provides assertion macros and evaluators for approximate equality of floating-point scalars and vectors in unit tests — filling gaps around f32 and f64 comparisons in Rust’s stock testing support.

§Installation

Reference in Cargo.toml in the usual way:

test_help-rs = { version = "0.1" }

§Components

§Macros

§Functions

§Types

§Constants

§Examples

use test_helpers::{assert_scalar_eq_approx, margin};

assert_scalar_eq_approx!(3.0, 3.0001, margin(0.0001));

See the project README for further information.

Modules§

constants
Constants.
traits
Traits.

Macros§

assert_scalar_eq_approx
Asserts that two scalar values are approximately equal.
assert_scalar_ne_approx
Asserts that two scalar values are not approximately equal.
assert_vector_eq_approx
Asserts that two vectors are approximately equal element-wise.
assert_vector_ne_approx
Asserts that two vectors are not approximately equal.

Enums§

ComparisonResult
Comparison result type.
VectorComparisonResult
Vector comparison result type.

Functions§

evaluate_scalar_eq_approx
Compares two scalar values using evaluator without asserting.
evaluate_vector_eq_approx
Compares two vectors element-wise using evaluator without asserting.
margin
Creates an ApproximateEqualityEvaluator that operates by applying the given factor as a margin to determine approximate equality.
multiplier
Creates an ApproximateEqualityEvaluator that operates by applying the given factor as a multiplier to determine approximate equality.
zero_margin_or_multiplier
Creates an ApproximateEqualityEvaluator that operates by applying the given multiplier_factor as a multiplier to determine approximate equality in all cases except when or both comparands is zero, in which case it applies the zero_margin_factor as a margin to determine approximate equality.