brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 4c35304 Raw
41 lines · cpp
1//===-- Unittests for atanhf16 --------------------------------------------===//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "hdr/stdint_proxy.h"10#include "src/math/atanhf16.h"11#include "test/UnitTest/FPMatcher.h"12#include "test/UnitTest/Test.h"13#include "utils/MPFRWrapper/MPFRUtils.h"14 15using LlvmLibcAtanhf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;16namespace mpfr = LIBC_NAMESPACE::testing::mpfr;17 18// Range for positive numbers: [0, +Inf]19static constexpr uint16_t POS_START = 0x0000U;20static constexpr uint16_t POS_STOP = 0x7C00U;21 22// Range for negative numbers: [-Inf, 0]23static constexpr uint16_t NEG_START = 0x8000U;24static constexpr uint16_t NEG_STOP = 0xFC00U;25 26TEST_F(LlvmLibcAtanhf16Test, PositiveRange) {27  for (uint16_t v = POS_START; v <= POS_STOP; ++v) {28    float16 x = FPBits(v).get_val();29    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atanh, x,30                                   LIBC_NAMESPACE::atanhf16(x), 0.5);31  }32}33 34TEST_F(LlvmLibcAtanhf16Test, NegativeRange) {35  for (uint16_t v = NEG_START; v <= NEG_STOP; ++v) {36    float16 x = FPBits(v).get_val();37    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atanh, x,38                                   LIBC_NAMESPACE::atanhf16(x), 0.5);39  }40}41