Add epsilon check macros for float comparison.

This commit is contained in:
Joao Paulo Magalhaes 2017-04-28 20:40:21 +01:00
parent e869e3749a
commit 8adf59d762
1 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@
#include <cstdlib>
#include <ostream>
#include <cmath>
#include "internal_macros.h"
#include "log.h"
@ -68,4 +69,11 @@ class CheckHandler {
#define CHECK_GT(a, b) CHECK((a) > (b))
#define CHECK_LT(a, b) CHECK((a) < (b))
#define CHECK_EQ_EPS(a, b, eps) CHECK(std::fabs((a) - (b)) < eps)
#define CHECK_NE_EPS(a, b, eps) CHECK(std::fabs((a) - (b)) >= eps)
#define CHECK_GE_EPS(a, b, eps) CHECK((a) - (b) > -eps)
#define CHECK_LE_EPS(a, b, eps) CHECK((b) - (a) > -eps)
#define CHECK_GT_EPS(a, b, eps) CHECK((a) - (b) > eps)
#define CHECK_LT_EPS(a, b, eps) CHECK((b) - (a) > eps)
#endif // CHECK_H_