mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
AK: Fix is_within_range when converting from float
Within range now uses the max capacity of a type rather than its size. This fixes some subtests in https://wpt.fyi/results/wasm/core/conversions.wast.js.html?product=ladybird
This commit is contained in:
parent
193163be2f
commit
b76f1fb011
Notes:
github-actions[bot]
2025-09-24 09:41:40 +00:00
Author: https://github.com/me-it-is
Commit: b76f1fb011
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6189
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 19 additions and 2 deletions
|
|
@ -445,3 +445,20 @@ TEST_CASE(should_constexpr_make_via_factory)
|
|||
{
|
||||
[[maybe_unused]] constexpr auto value = make_checked(42);
|
||||
}
|
||||
|
||||
TEST_CASE(is_within_range_float_to_int)
|
||||
{
|
||||
static_assert(AK::is_within_range<int>(0.0));
|
||||
static_assert(AK::is_within_range<int>(0.0f));
|
||||
static_assert(AK::is_within_range<int>(((long double)0.0)));
|
||||
|
||||
static_assert(!AK::is_within_range<int>(NumericLimits<float>::max()));
|
||||
static_assert(!AK::is_within_range<int>(NumericLimits<double>::max()));
|
||||
static_assert(!AK::is_within_range<int>(NumericLimits<long double>::max()));
|
||||
static_assert(!AK::is_within_range<int>(NumericLimits<float>::lowest()));
|
||||
|
||||
static_assert(AK::is_within_range<long>(0.0));
|
||||
static_assert(AK::is_within_range<long long>(0.0));
|
||||
|
||||
static_assert(!AK::is_within_range<int>(NAN));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue