1 //===-- Exhaustive test for asinf -----------------------------------------===//
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/asinf.h"
12 #include "utils/MPFRWrapper/MPFRUtils.h"
16 using FPBits
= __llvm_libc::fputil::FPBits
<float>;
18 namespace mpfr
= __llvm_libc::testing::mpfr
;
20 struct LlvmLibcAsinfExhaustiveTest
: 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::Asin
, x
,
30 __llvm_libc::asinf(x
), 0.5, rounding
);
31 // if (!result) break;
32 } while (bits
++ < stop
);
37 static const int NUM_THREADS
= std::thread::hardware_concurrency();
40 static const uint32_t POS_START
= 0x0000'0000U
;
41 static const uint32_t POS_STOP
= 0x7f80'0000U
;
43 TEST_F(LlvmLibcAsinfExhaustiveTest
, PostiveRangeRoundNearestTieToEven
) {
44 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Nearest
);
47 TEST_F(LlvmLibcAsinfExhaustiveTest
, PostiveRangeRoundUp
) {
48 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Upward
);
51 TEST_F(LlvmLibcAsinfExhaustiveTest
, PostiveRangeRoundDown
) {
52 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::Downward
);
55 TEST_F(LlvmLibcAsinfExhaustiveTest
, PostiveRangeRoundTowardZero
) {
56 test_full_range(POS_START
, POS_STOP
, mpfr::RoundingMode::TowardZero
);
60 static const uint32_t NEG_START
= 0x8000'0000U
;
61 static const uint32_t NEG_STOP
= 0xff80'0000U
;
63 TEST_F(LlvmLibcAsinfExhaustiveTest
, NegativeRangeRoundNearestTieToEven
) {
64 test_full_range(NEG_START
, NEG_STOP
, mpfr::RoundingMode::Nearest
);
67 TEST_F(LlvmLibcAsinfExhaustiveTest
, NegativeRangeRoundUp
) {
68 test_full_range(NEG_START
, NEG_STOP
, mpfr::RoundingMode::Upward
);
71 TEST_F(LlvmLibcAsinfExhaustiveTest
, NegativeRangeRoundDown
) {
72 test_full_range(NEG_START
, NEG_STOP
, mpfr::RoundingMode::Downward
);
75 TEST_F(LlvmLibcAsinfExhaustiveTest
, NegativeRangeRoundTowardZero
) {
76 test_full_range(NEG_START
, NEG_STOP
, mpfr::RoundingMode::TowardZero
);