summaryrefslogtreecommitdiff
path: root/libs/greatest
diff options
context:
space:
mode:
Diffstat (limited to 'libs/greatest')
-rw-r--r--libs/greatest/greatest.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/libs/greatest/greatest.h b/libs/greatest/greatest.h
index 58f12b5..06fcca9 100644
--- a/libs/greatest/greatest.h
+++ b/libs/greatest/greatest.h
@@ -17,6 +17,8 @@
#ifndef GREATEST_H
#define GREATEST_H
+#include <math.h>
+
#if defined(__cplusplus) && !defined(GREATEST_NO_EXTERN_CPLUSPLUS)
extern "C" {
#endif
@@ -436,6 +438,8 @@ typedef enum greatest_test_res {
GREATEST_ASSERT_FALSEm(#COND, COND)
#define GREATEST_ASSERT_EQ(EXP, GOT) \
GREATEST_ASSERT_EQm(#EXP " != " #GOT, EXP, GOT)
+#define GREATEST_ASSERT_FEQ(EXP, GOT) \
+ GREATEST_ASSERT_FEQm(#EXP " != " #GOT, EXP, GOT)
#define GREATEST_ASSERT_NEQ(EXP, GOT) \
GREATEST_ASSERT_NEQm(#EXP " == " #GOT, EXP, GOT)
#define GREATEST_ASSERT_GT(EXP, GOT) \
@@ -500,6 +504,12 @@ typedef enum greatest_test_res {
#define GREATEST_ASSERT_LTm(MSG,E,G) GREATEST__REL(<, MSG,E,G)
#define GREATEST_ASSERT_LTEm(MSG,E,G) GREATEST__REL(<=, MSG,E,G)
+#define GREATEST_ASSERT_FEQm(MSG, EXP, GOT) \
+ do { \
+ greatest_info.assertions++; \
+ if (fabs(EXP - GOT) > 0.001f) { GREATEST_FAILm(MSG); } \
+ } while (0)
+
/* Fail if EXP != GOT (equality comparison by ==).
* Warning: FMT, EXP, and GOT will be evaluated more
* than once on failure. */
@@ -1208,6 +1218,7 @@ greatest_run_info greatest_info
#define ASSERTm GREATEST_ASSERTm
#define ASSERT_FALSE GREATEST_ASSERT_FALSE
#define ASSERT_EQ GREATEST_ASSERT_EQ
+#define ASSERT_FEQ GREATEST_ASSERT_FEQ
#define ASSERT_NEQ GREATEST_ASSERT_NEQ
#define ASSERT_GT GREATEST_ASSERT_GT
#define ASSERT_GTE GREATEST_ASSERT_GTE