Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/projects/SelfTest/UsageTests
diff options
context:
space:
mode:
authorMartin Hořeňovský2019-10-20 12:30:21 +0200
committerMartin Hořeňovský2019-10-20 12:30:21 +0200
commit9e8ae7d4701770c3f4f23414214634f59809fa71 (patch)
tree5912dc8261c60ceb2741fa2a459e3d40fa7516fe /projects/SelfTest/UsageTests
parent84856844e17f78e9f3a9f113df9d3ff23aad69e1 (diff)
downloadcatch3-9e8ae7d4701770c3f4f23414214634f59809fa71.tar.gz
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
Diffstat (limited to 'projects/SelfTest/UsageTests')
-rw-r--r--projects/SelfTest/UsageTests/Matchers.tests.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/projects/SelfTest/UsageTests/Matchers.tests.cpp b/projects/SelfTest/UsageTests/Matchers.tests.cpp
index 6f954ca0..80e0420f 100644
--- a/projects/SelfTest/UsageTests/Matchers.tests.cpp
+++ b/projects/SelfTest/UsageTests/Matchers.tests.cpp
@@ -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));