diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-09 12:35:16 -0400 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-04-09 12:35:16 -0400 |
| commit | 3aa4bf34cf1f8a710764bfd35849c2474589bf2e (patch) | |
| tree | a134799ed41152806f868754a83595b10888b346 /tests/pke-test-types.h | |
| parent | 63ce7559ce34505eec576fcf43c7cb62a814f31a (diff) | |
pke-test: compare floats using epsilon
Diffstat (limited to 'tests/pke-test-types.h')
| -rw-r--r-- | tests/pke-test-types.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/pke-test-types.h b/tests/pke-test-types.h index 5a9ee24..097d42f 100644 --- a/tests/pke-test-types.h +++ b/tests/pke-test-types.h @@ -3,6 +3,7 @@ #include <setjmp.h> #include <stdint.h> +#include <cmath> struct pke_test_long_jump { uint8_t expected_exit; @@ -38,4 +39,9 @@ struct pke_test_group { #define PKE_TEST_ASSERT(condition, index) if (!(condition)) { return ++index; } else { ++index; } +template<typename T> +inline bool flt_equal(T a, T b, T epsilon) { + return std::abs(a - b) < epsilon; +} + #endif /* PKE_PKE_TEST_TYPES_H */ |
