Skip to content

Commit ec505e5

Browse files
committed
Added negative exhaustive test
1 parent 24c5d78 commit ec505e5

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

libc/test/src/math/exhaustive/hypotf16_test.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@
1515

1616
namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
1717

18-
// Range of both inputs: [0, inf]
19-
static constexpr uint16_t START = 0x0000U;
20-
static constexpr uint16_t STOP = 0x7C00U;
21-
2218
struct Hypotf16Checker : public virtual LIBC_NAMESPACE::testing::Test {
2319
using FloatType = float16;
2420
using FPBits = LIBC_NAMESPACE::fputil::FPBits<float16>;
2521
using StorageType = typename FPBits::StorageType;
2622

27-
uint64_t check(uint16_t start, uint16_t stop, mpfr::RoundingMode rounding) {
23+
uint64_t check(uint16_t x_start, uint16_t x_stop, uint16_t y_start,
24+
uint16_t y_stop, mpfr::RoundingMode rounding) {
2825
mpfr::ForceRoundingMode r(rounding);
2926
if (!r.success)
3027
return true;
31-
uint16_t xbits = start;
28+
uint16_t xbits = x_start;
3229
uint64_t failed = 0;
3330
do {
3431
float16 x = FPBits(xbits).get_val();
@@ -44,15 +41,27 @@ struct Hypotf16Checker : public virtual LIBC_NAMESPACE::testing::Test {
4441
// 0.5,
4542
// rounding);
4643
failed += (!correct);
47-
} while (ybits++ < STOP);
48-
} while (xbits++ < stop);
44+
} while (ybits++ < y_stop);
45+
} while (xbits++ < x_stop);
4946
return failed;
5047
}
5148
};
5249

5350
using LlvmLibcHypotf16ExhaustiveTest =
5451
LlvmLibcExhaustiveMathTest<Hypotf16Checker, 1 << 2>;
5552

53+
// Range of both inputs: [0, inf]
54+
static constexpr uint16_t POS_START = 0x0000U;
55+
static constexpr uint16_t POS_STOP = 0x7C00U;
56+
5657
TEST_F(LlvmLibcHypotf16ExhaustiveTest, PositiveRange) {
57-
test_full_range_all_roundings(START, STOP);
58+
test_full_range_all_roundings(POS_START, POS_STOP, POS_START, POS_STOP);
59+
}
60+
61+
// Range of both inputs: [-0, -inf]
62+
static constexpr uint16_t NEG_START = 0x8000U;
63+
static constexpr uint16_t NEG_STOP = 0xFC00U;
64+
65+
TEST_F(LlvmLibcHypotf16ExhaustiveTest, NegativeRange) {
66+
test_full_range_all_roundings(NEG_START, NEG_STOP, NEG_START, NEG_STOP);
5867
}

0 commit comments

Comments
 (0)