[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / test / src / math / asinhf_test.cpp
blobd2c6584454abec154a1146223c4f54067f8b212e
1 //===-- Unittests for asinhf ----------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/FPUtil/FPBits.h"
10 #include "src/math/asinhf.h"
11 #include "test/UnitTest/FPMatcher.h"
12 #include "test/UnitTest/Test.h"
13 #include "utils/MPFRWrapper/MPFRUtils.h"
14 #include <math.h>
16 #include <errno.h>
17 #include <stdint.h>
19 using FPBits_t = __llvm_libc::fputil::FPBits<float>;
21 namespace mpfr = __llvm_libc::testing::mpfr;
23 DECLARE_SPECIAL_CONSTANTS(float)
25 TEST(LlvmLibcAsinhfTest, SpecialNumbers) {
26 errno = 0;
28 EXPECT_FP_EQ(aNaN, __llvm_libc::asinhf(aNaN));
29 EXPECT_MATH_ERRNO(0);
31 EXPECT_FP_EQ(0.0f, __llvm_libc::asinhf(0.0f));
32 EXPECT_MATH_ERRNO(0);
34 EXPECT_FP_EQ(-0.0f, __llvm_libc::asinhf(-0.0f));
35 EXPECT_MATH_ERRNO(0);
37 EXPECT_FP_EQ(inf, __llvm_libc::asinhf(inf));
38 EXPECT_MATH_ERRNO(0);
40 EXPECT_FP_EQ(neg_inf, __llvm_libc::asinhf(neg_inf));
41 EXPECT_MATH_ERRNO(0);
44 TEST(LlvmLibcAsinhfTest, InFloatRange) {
45 constexpr uint32_t COUNT = 1000000;
46 constexpr uint32_t STEP = UINT32_MAX / COUNT;
47 for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
48 float x = float(FPBits_t(v));
49 if (isnan(x) || isinf(x))
50 continue;
51 ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
52 __llvm_libc::asinhf(x), 0.5);
53 ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, -x,
54 __llvm_libc::asinhf(-x), 0.5);
58 TEST(LlvmLibcAsinhfTest, SpecificBitPatterns) {
59 constexpr int N = 11;
60 constexpr uint32_t INPUTS[N] = {
61 0x45abaf26, // |x| = 0x1.575e4cp12f
62 0x49d29048, // |x| = 0x1.a5209p20f
63 0x4bdd65a5, // |x| = 0x1.bacb4ap24f
64 0x4c803f2c, // |x| = 0x1.007e58p26f
65 0x4f8ffb03, // |x| = 0x1.1ff606p32f
66 0x5c569e88, // |x| = 0x1.ad3d1p57f
67 0x5e68984e, // |x| = 0x1.d1309cp61f
68 0x655890d3, // |x| = 0x1.b121a6p75f
69 0x65de7ca6, // |x| = 0x1.bcf94cp76f
70 0x6eb1a8ec, // |x| = 0x1.6351d8p94f
71 0x7997f30a, // |x| = 0x1.2fe614p116f
74 for (int i = 0; i < N; ++i) {
75 float x = float(FPBits_t(INPUTS[i]));
76 EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x,
77 __llvm_libc::asinhf(x), 0.5);
78 EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, -x,
79 __llvm_libc::asinhf(-x), 0.5);