Skip to content

Commit f7a0c40

Browse files
committed
I think I found out what the issue was --I wasn't using from_float()
1 parent 6559dc1 commit f7a0c40

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

tests/Nat/casting.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,11 @@ TEST_CASE("Casting arby::Nat with value higher than UINT_MAX to uintmax_t throws
2121
CHECK_THROWS_AS((uintmax_t)value, std::range_error);
2222
}
2323

24-
TEST_CASE("Casting arby::Nat to float", "[casting]") {
24+
TEMPLATE_TEST_CASE("Casting arby::Nat to various floating-point types", "[casting]", float, double, long double) {
2525
auto value = GENERATE(take(1000, random((uintmax_t)0, std::numeric_limits<uintmax_t>::max())));
2626

2727
// float is so imprecise for large values that we need to cast the input too
28-
CHECK((float)arby::Nat((long double)(float)value) == (float)value);
29-
}
30-
31-
TEST_CASE("Casting arby::Nat to double", "[casting]") {
32-
auto value = GENERATE(take(1000, random((uintmax_t)0, std::numeric_limits<uintmax_t>::max())));
33-
34-
CHECK((double)arby::Nat(value) == (double)value);
35-
}
36-
37-
TEST_CASE("Casting arby::Nat to long double", "[casting]") {
38-
auto value = GENERATE(take(1000, random((uintmax_t)0, std::numeric_limits<uintmax_t>::max())));
39-
40-
CHECK((long double)arby::Nat(value) == (long double)value);
28+
CHECK((TestType)arby::Nat::from_float((TestType)value) == (TestType)value);
4129
}
4230

4331
TEMPLATE_TEST_CASE(

0 commit comments

Comments
 (0)