1 //===-- Exhaustive test for acoshf ----------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "exhaustive_test.h"
10 #include "src/__support/FPUtil/FPBits.h"
11 #include "src/math/acoshf.h"
12 #include "utils/MPFRWrapper/MPFRUtils.h"
16 using FPBits
= __llvm_libc::fputil::FPBits
<float>;
18 namespace mpfr
= __llvm_libc::testing::mpfr
;
20 struct LlvmLibcAcoshfExhaustiveTest
: public LlvmLibcExhaustiveTest
<uint32_t> {
21 bool check(uint32_t start
, uint32_t stop
,
22 mpfr::RoundingMode rounding
) override
{
23 mpfr::ForceRoundingMode
r(rounding
);
24 uint32_t bits
= start
;
28 float x
= float(xbits
);
29 result
&= EXPECT_MPFR_MATCH(mpfr::Operation::Acosh
, x
,
30 __llvm_libc::acoshf(x
), 0.5, rounding
);
31 } while (bits
++ < stop
);
36 static const int NUM_THREADS
= std::thread::hardware_concurrency();
39 static const uint32_t POS_START
= 0x3f80'0000U
;
40 static const uint32_t POS_STOP
= 0x7f80'0000U
;
42 TEST_F(LlvmLibcAcoshfExhaustiveTest
, PostiveRangeRoundNearestTieToEven
) {
43 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Nearest
);
46 TEST_F(LlvmLibcAcoshfExhaustiveTest
, PostiveRangeRoundUp
) {
47 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Upward
);
50 TEST_F(LlvmLibcAcoshfExhaustiveTest
, PostiveRangeRoundDown
) {
51 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Downward
);
54 TEST_F(LlvmLibcAcoshfExhaustiveTest
, PostiveRangeRoundTowardZero
) {
55 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::TowardZero
);