Added debug info for failing tests
This commit is contained in:
@@ -36,11 +36,15 @@ TEST_CASE("Infinity and NaN", "[float16]")
|
||||
fp16 neg_inf = -std::numeric_limits<fp16>::infinity();
|
||||
fp16 nan_val = std::numeric_limits<fp16>::quiet_NaN();
|
||||
|
||||
REQUIRE(std::isinf(static_cast<float>(pos_inf)));
|
||||
REQUIRE(std::isinf(static_cast<float>(neg_inf)));
|
||||
REQUIRE(std::isnan(static_cast<float>(nan_val)));
|
||||
REQUIRE(pos_inf > fp16(65504.0f));
|
||||
REQUIRE(neg_inf < fp16(-65504.0f));
|
||||
INFO("Value of pos_inf: " << static_cast<float>(pos_inf));
|
||||
INFO("Value of nan_val: " << static_cast<float>(nan_val));
|
||||
INFO("Result of comparison: " << (nan_val != nan_val));
|
||||
|
||||
CHECK(std::isinf(static_cast<float>(pos_inf)));
|
||||
CHECK(std::isinf(static_cast<float>(neg_inf)));
|
||||
CHECK(std::isnan(static_cast<float>(nan_val)));
|
||||
CHECK(pos_inf > fp16(65504.0f));
|
||||
CHECK(neg_inf < fp16(-65504.0f));
|
||||
}
|
||||
|
||||
TEST_CASE("Denormalized Values", "[float16]")
|
||||
@@ -58,11 +62,13 @@ TEST_CASE("Special Cases", "[float16]")
|
||||
fp16 min_normal(std::numeric_limits<fp16>::min());
|
||||
fp16 max_fp(std::numeric_limits<fp16>::max());
|
||||
|
||||
REQUIRE(almostEqual(static_cast<float>(zero), 0.0f));
|
||||
REQUIRE(almostEqual(static_cast<float>(neg_zero), 0.0f));
|
||||
REQUIRE(almostEqual(static_cast<float>(epsilon_fp), 0.00097656f));
|
||||
REQUIRE(almostEqual(static_cast<float>(min_normal), 6.10352e-5f));
|
||||
REQUIRE(almostEqual(static_cast<float>(max_fp), 65504.0f));
|
||||
INFO("Value of max_fp: " << static_cast<float>(max_fp));
|
||||
|
||||
CHECK(almostEqual(static_cast<float>(zero), 0.0f));
|
||||
CHECK(almostEqual(static_cast<float>(neg_zero), 0.0f));
|
||||
CHECK(almostEqual(static_cast<float>(epsilon_fp), 0.00097656f));
|
||||
CHECK(almostEqual(static_cast<float>(min_normal), 6.10352e-5f));
|
||||
CHECK(almostEqual(static_cast<float>(max_fp), 65504.0f));
|
||||
}
|
||||
|
||||
TEST_CASE("Arithmetic Operations", "[float16]")
|
||||
@@ -83,18 +89,26 @@ TEST_CASE("Comparisons", "[float16]")
|
||||
{
|
||||
fp16 a(1.0f), b(2.0f), zero(0.0f), neg(-1.0f), inf = std::numeric_limits<fp16>::infinity();
|
||||
|
||||
REQUIRE(a < b);
|
||||
REQUIRE(b > a);
|
||||
REQUIRE(zero == -zero);
|
||||
REQUIRE(a != neg);
|
||||
REQUIRE(inf > b);
|
||||
REQUIRE(!(inf < b));
|
||||
INFO("Value of inf: " << static_cast<float>(inf));
|
||||
INFO("Value of zero: " << static_cast<float>(zero));
|
||||
INFO("Value of neg: " << static_cast<float>(neg));
|
||||
|
||||
CHECK(a < b);
|
||||
CHECK(b > a);
|
||||
CHECK(zero == -zero);
|
||||
CHECK(a != neg);
|
||||
CHECK(inf > b);
|
||||
CHECK(!(inf < b));
|
||||
}
|
||||
|
||||
TEST_CASE("Arithmetic with Special Values", "[float16]")
|
||||
{
|
||||
fp16 a(2.0f), inf = std::numeric_limits<fp16>::infinity(), nan = std::numeric_limits<fp16>::quiet_NaN();
|
||||
|
||||
INFO("Value of a: " << static_cast<float>(a));
|
||||
INFO("Value of inf: " << static_cast<float>(inf));
|
||||
INFO("Value of nan: " << static_cast<float>(nan));
|
||||
|
||||
REQUIRE(std::isinf(static_cast<float>(a + inf)));
|
||||
REQUIRE(std::isinf(static_cast<float>(inf - a)));
|
||||
REQUIRE(std::isnan(static_cast<float>(inf - inf)));
|
||||
@@ -132,8 +146,13 @@ TEST_CASE("Special Comparison with Infinity and NaN", "[float16]")
|
||||
fp16 nan = std::numeric_limits<fp16>::quiet_NaN();
|
||||
fp16 one(1.0f);
|
||||
|
||||
REQUIRE(inf > one);
|
||||
REQUIRE(neg_inf < -one);
|
||||
REQUIRE(std::isnan(static_cast<float>(nan)));
|
||||
REQUIRE(nan != nan);
|
||||
INFO("Value of one: " << static_cast<float>(one));
|
||||
INFO("Value of inf: " << static_cast<float>(inf));
|
||||
INFO("Value of neg_inf: " << static_cast<float>(neg_inf));
|
||||
INFO("Value of nan: " << static_cast<float>(nan));
|
||||
|
||||
CHECK(inf > one);
|
||||
CHECK(neg_inf < -one);
|
||||
CHECK(std::isnan(static_cast<float>(nan)));
|
||||
CHECK(nan != nan);
|
||||
}
|
||||
Reference in New Issue
Block a user