kaycxx-test
C++ unit test framework
Loading...
Searching...
No Matches
assert_close

Asserts that two numeric values are equal after rounding to a decimal precision.

The default precision is 2 decimal digits. Integral values are compared exactly. Boolean values are rejected because closeness is a numeric relation, not a truth-value relation.

#include <kaycxx/test.hpp>
using namespace kaycxx::test;
int main() {
assert_close(1.234, 1.233);
assert_close(3.14159, 3.142, 3);
assert_close(42, 42);
}
Unit test framework functions and types.
Definition test.hpp:15
Includes the complete public test API.

Use assert_close for result values where small floating-point differences are acceptable after rounding.