48 lines · cpp
1//===-- Exhaustive test for sinf - float-only -----------------------------===//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// Test float-only fast math implementation for sinf.10#define LIBC_MATH (LIBC_MATH_FAST | LIBC_MATH_INTERMEDIATE_COMP_IN_FLOAT)11 12#include "exhaustive_test.h"13#include "src/__support/math/sincosf_float_eval.h"14#include "utils/MPFRWrapper/MPFRUtils.h"15 16namespace mpfr = LIBC_NAMESPACE::testing::mpfr;17 18float sinf_fast(float x) {19 return LIBC_NAMESPACE::math::sincosf_float_eval::sincosf_eval<20 /*IS_SIN*/ true>(x);21}22 23using LlvmLibcSinfExhaustiveTest =24 LlvmLibcUnaryOpExhaustiveMathTest<float, mpfr::Operation::Sin, sinf_fast,25 3>;26 27// Range: [0, Inf];28static constexpr uint32_t POS_START = 0x0000'0000U;29static constexpr uint32_t POS_STOP = 0x7f80'0000U;30 31TEST_F(LlvmLibcSinfExhaustiveTest, PostiveRange) {32 std::cout << "-- Testing for FE_TONEAREST in range [0x" << std::hex33 << POS_START << ", 0x" << POS_STOP << ") --" << std::dec34 << std::endl;35 test_full_range(mpfr::RoundingMode::Nearest, POS_START, POS_STOP);36}37 38// Range: [-Inf, 0];39static constexpr uint32_t NEG_START = 0x8000'0000U;40static constexpr uint32_t NEG_STOP = 0xff80'0000U;41 42TEST_F(LlvmLibcSinfExhaustiveTest, NegativeRange) {43 std::cout << "-- Testing for FE_TONEAREST in range [0x" << std::hex44 << NEG_START << ", 0x" << NEG_STOP << ") --" << std::dec45 << std::endl;46 test_full_range(mpfr::RoundingMode::Nearest, NEG_START, NEG_STOP);47}48