Source

mana-core-testtools / TestTools / FLOATassert.h

Full commit
/**  functions & macros to test the difference between floats */
#ifndef TESTTOOLS_FLOATASSERT_H
#define TESTTOOLS_FLOATASSERT_H

#include <cassert>
#include <cfloat>
#include <cmath>

#undef NDEBUG

namespace Athena_test {
  bool floatEQ(float lhs, float rhs) {
    return fabs(lhs-rhs)<=FLT_EPSILON;
  }
  bool floatNEQ(float lhs, float rhs) {
    return fabs(lhs-rhs)>FLT_EPSILON;
  }
}

#define FLOAT_NEQassert( LHS, RHS ) assert(Athena_test::floatNEQ(LHS, RHS));	
#define FLOAT_EQassert( LHS, RHS ) assert(Athena_test::floatEQ(LHS, RHS));	

#endif