Use approx when testing floating point approximate equality.

This commit is contained in:
Matt Amos 2015-05-18 22:45:52 +01:00
parent 369887428e
commit 782a949543
2 changed files with 5 additions and 5 deletions

View file

@ -641,7 +641,7 @@ TEST_CASE("csv") {
for (double d : { .0, +.0, 1e-06, -1e-06, 0.000001, 1.234e+16, 1.234e+16 }) { for (double d : { .0, +.0, 1e-06, -1e-06, 0.000001, 1.234e+16, 1.234e+16 }) {
auto feature = fs->next(); auto feature = fs->next();
REQUIRE(bool(feature)); REQUIRE(bool(feature));
CHECK(feature->get("floats") == d); CHECK(feature->get("floats").get<mapnik::value_double>() == Approx(d));
} }
} // END SECTION } // END SECTION

View file

@ -98,10 +98,10 @@ SECTION("envelope multiplication") {
auto a = mapnik::box2d<double>(100.0, 100.0, 100.001, 100.001); auto a = mapnik::box2d<double>(100.0, 100.0, 100.001, 100.001);
a *= 5; a *= 5;
REQUIRE(std::abs(a.minx() - 99.9980) < 0.001); REQUIRE(a.minx() == Approx( 99.9980));
REQUIRE(std::abs(a.miny() - 99.9980) < 0.001); REQUIRE(a.miny() == Approx( 99.9980));
REQUIRE(std::abs(a.maxx() - 100.0030) < 0.001); REQUIRE(a.maxx() == Approx(100.0030));
REQUIRE(std::abs(a.maxy() - 100.0030) < 0.001); REQUIRE(a.maxy() == Approx(100.0030));
} }
{ {