diff options
Diffstat (limited to 'test/test_helpers.c')
-rw-r--r-- | test/test_helpers.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_helpers.c b/test/test_helpers.c new file mode 100644 index 0000000000..187ff73c61 --- /dev/null +++ b/test/test_helpers.c @@ -0,0 +1,29 @@ +#include <inttypes.h> + +#include "test_helpers.h" + +void assert_int_equal_impl(const char *file, int line, int64_t a, int64_t b) +{ + if (a != b) { + printf("%s:%d: %"PRId64" != %"PRId64"\n", file, line, a, b); + abort(); + } +} + +void assert_string_equal_impl(const char *file, int line, + const char *a, const char *b) +{ + if (strcmp(a, b) != 0) { + printf("%s:%d: '%s' != '%s'\n", file, line, a, b); + abort(); + } +} + +void assert_float_equal_impl(const char *file, int line, + double a, double b, double tolerance) +{ + if (fabs(a - b) > tolerance) { + printf("%s:%d: %f != %f\n", file, line, a, b); + abort(); + } +} |