brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 4d35309 Raw
51 lines · cpp
1//===-- Unittests for supfuncf --------------------------------------------===//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/math_macros.h"10#include "in_float_range_test_helper.h"11#include "src/__support/FPUtil/FPBits.h"12#include "src/__support/math/acoshf_utils.h"13#include "src/__support/math/exp10f_utils.h"14#include "src/math/fabs.h"15#include "src/math/fabsf.h"16#include "test/UnitTest/FPMatcher.h"17#include "utils/MPFRWrapper/MPFRUtils.h"18 19using LlvmLibcExplogfTest = LIBC_NAMESPACE::testing::FPTest<float>;20using FPBits = LIBC_NAMESPACE::fputil::FPBits<float>;21 22namespace mpfr = LIBC_NAMESPACE::testing::mpfr;23 24constexpr int def_count = 100003;25constexpr float def_prec = 0.500001f;26 27auto f_normal = [](float x) -> bool {28  return !(FPBits(x).is_nan() || FPBits(x).is_inf() ||29           LIBC_NAMESPACE::fabs(x) < 2E-38);30};31 32TEST_F(LlvmLibcExplogfTest, ExpInFloatRange) {33  auto fx = [](float x) -> float {34    auto result = LIBC_NAMESPACE::exp_b_range_reduc<LIBC_NAMESPACE::ExpBase>(x);35    double r = LIBC_NAMESPACE::ExpBase::powb_lo(result.lo);36    return static_cast<float>(result.mh * r);37  };38  auto f_check = [](float x) -> bool {39    return !((FPBits(x).is_nan() || FPBits(x).is_inf() || x < -70 || x > 70 ||40              LIBC_NAMESPACE::fabsf(x) < 0x1.0p-10));41  };42  CHECK_DATA(0.0f, neg_inf, mpfr::Operation::Exp, fx, f_check, def_count,43             def_prec);44}45 46TEST_F(LlvmLibcExplogfTest, LogInFloatRange) {47  CHECK_DATA(0.0f, inf, mpfr::Operation::Log,48             LIBC_NAMESPACE::acoshf_internal::log_eval, f_normal, def_count,49             def_prec);50}51