Use scientific notation for the WithinULP matcher

This should now properly handle small numbers which would previously
output something like `[0.00000000000000019, 0.00000000000000019]`,
which does not allow user to read the numbers properly.

Closes #1760
This commit is contained in:
Martin Hořeňovský
2019-10-20 12:30:21 +02:00
parent 84856844e1
commit 9e8ae7d470
7 changed files with 129 additions and 88 deletions

View File

@@ -382,8 +382,9 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
REQUIRE_THAT(nextafter(1.f, 2.f), WithinULP(1.f, 1));
REQUIRE_THAT(nextafter(1.f, 0.f), WithinULP(1.f, 1));
REQUIRE_THAT(nextafter(1.f, 2.f), !WithinULP(1.f, 0));
REQUIRE_THAT(0.f, WithinULP(nextafter(0.f, 1.f), 1));
REQUIRE_THAT(1.f, WithinULP(nextafter(1.f, 0.f), 1));
REQUIRE_THAT(1.f, !WithinULP(nextafter(1.f, 2.f), 0));
REQUIRE_THAT(1.f, WithinULP(1.f, 0));
REQUIRE_THAT(-0.f, WithinULP(0.f, 0));
@@ -437,8 +438,9 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(1., WithinULP(1., 0));
REQUIRE_THAT(nextafter(1., 2.), WithinULP(1., 1));
REQUIRE_THAT(nextafter(1., 0.), WithinULP(1., 1));
REQUIRE_THAT(nextafter(1., 2.), !WithinULP(1., 0));
REQUIRE_THAT(0., WithinULP(nextafter(0., 1.), 1));
REQUIRE_THAT(1., WithinULP(nextafter(1., 0.), 1));
REQUIRE_THAT(1., !WithinULP(nextafter(1., 2.), 0));
REQUIRE_THAT(1., WithinULP(1., 0));
REQUIRE_THAT(-0., WithinULP(0., 0));