Avoid floating point equality checks in tests

Make newer Apple clangs happy even with -Wfloat-equal

Change-Id: I186c03811b3ed582f740afd3f01ea09090e6b7e1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/33600
Commit-Queue: David Neto <dneto@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: David Neto <dneto@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
David Neto 2020-11-20 19:34:34 +00:00 committed by Commit Bot service account
parent ca03041ad7
commit 189ceb6703
1 changed files with 8 additions and 4 deletions

View File

@ -43,8 +43,9 @@ TEST(FloatToStringTest, Small) {
}
TEST(FloatToStringTest, Highest) {
if (std::numeric_limits<float>::max() !=
340282346638528859811704183484516925440.0f) {
const auto highest = std::numeric_limits<float>::max();
const auto expected_highest = 340282346638528859811704183484516925440.0f;
if (highest < expected_highest || highest > expected_highest) {
GTEST_SKIP() << "std::numeric_limits<float>::max() is not as expected for "
"this target";
}
@ -53,8 +54,11 @@ TEST(FloatToStringTest, Highest) {
}
TEST(FloatToStringTest, Lowest) {
if (std::numeric_limits<float>::lowest() !=
-340282346638528859811704183484516925440.0f) {
// Some compilers complain if you test floating point numbers for equality.
// So say it via two inequalities.
const auto lowest = std::numeric_limits<float>::lowest();
const auto expected_lowest = -340282346638528859811704183484516925440.0f;
if (lowest < expected_lowest || lowest > expected_lowest) {
GTEST_SKIP()
<< "std::numeric_limits<float>::lowest() is not as expected for "
"this target";