X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fenvironment%2Ftest_metar.cxx;h=814094b2eea8b66ccc32721d2af7d409791d4f4f;hb=be7065674586ffbb5940ab21a028bc8c461217e2;hp=bcdc772598d298ac23a54c6374338fd216587352;hpb=63a8209a839fcc142ab86ef16f323bb54c37521a;p=simgear.git diff --git a/simgear/environment/test_metar.cxx b/simgear/environment/test_metar.cxx index bcdc7725..814094b2 100644 --- a/simgear/environment/test_metar.cxx +++ b/simgear/environment/test_metar.cxx @@ -30,12 +30,20 @@ using std::string; exit(1); \ } +#define FUZZY_COMPARE(a, b, epsilon) \ + if (fabs(a - b) > epsilon) { \ + cerr << "failed:" << #a << " != " << #b << endl; \ + cerr << "\tgot:" << a << endl; \ + cerr << "\tepsilon:" << epsilon << endl; \ + } + #define VERIFY(a) \ if (!(a)) { \ cerr << "failed:" << #a << endl; \ exit(1); \ } - + +const double TEST_EPSILON = 1e-9; void test_basic() { @@ -48,11 +56,11 @@ void test_basic() COMPARE(m1.getReportType(), -1); // should default to NIL? COMPARE(m1.getWindDir(), 270); - COMPARE(m1.getWindSpeed_kt(), 12); + FUZZY_COMPARE(m1.getWindSpeed_kt(), 12, TEST_EPSILON); - COMPARE(m1.getTemperature_C(), 10); - COMPARE(m1.getDewpoint_C(), 5); - COMPARE(m1.getPressure_hPa(), 1025); + FUZZY_COMPARE(m1.getTemperature_C(), 10, TEST_EPSILON); + FUZZY_COMPARE(m1.getDewpoint_C(), 5, TEST_EPSILON); + FUZZY_COMPARE(m1.getPressure_hPa(), 1025, TEST_EPSILON); } int main(int argc, char* argv[])