Skip to content

Commit 5c26e93

Browse files
committed
Try fix compare double values in unit-tests
1 parent 58a56a8 commit 5c26e93

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/wsjcpp_unit_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "wsjcpp_unit_tests.h"
2+
#include <cmath>
23

34
WsjcppUnitTestBase::WsjcppUnitTestBase(const std::string &sTestName) {
45
m_sTestName = sTestName;
@@ -36,7 +37,7 @@ bool WsjcppUnitTestBase::compareN(bool &bTestSuccess, const std::string &sPoint,
3637
// ---------------------------------------------------------------------
3738

3839
bool WsjcppUnitTestBase::compareD(bool &bTestSuccess, const std::string &sPoint, double nValue, double nExpected) {
39-
if (nValue != nExpected) {
40+
if (abs(nValue - nExpected) > std::numeric_limits<double>::epsilon()) {
4041
WsjcppLog::err(TAG, " {" + sPoint + "} Expected '" + std::to_string(nExpected) + "', but got '" + std::to_string(nValue) + "'");
4142
bTestSuccess = false;
4243
return false;

0 commit comments

Comments
 (0)