45 lines · cpp
1//===-- Exhaustive test for cosf - 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#include "exhaustive_test.h"10#include "src/__support/math/sincosf_float_eval.h"11#include "utils/MPFRWrapper/MPFRUtils.h"12 13namespace mpfr = LIBC_NAMESPACE::testing::mpfr;14 15float cosf_fast(float x) {16 return LIBC_NAMESPACE::math::sincosf_float_eval::sincosf_eval<17 /*IS_SIN*/ false>(x);18}19 20using LlvmLibcCosfExhaustiveTest =21 LlvmLibcUnaryOpExhaustiveMathTest<float, mpfr::Operation::Cos, cosf_fast,22 3>;23 24// Range: [0, Inf];25static constexpr uint32_t POS_START = 0x0000'0000U;26static constexpr uint32_t POS_STOP = 0x7f80'0000U;27 28TEST_F(LlvmLibcCosfExhaustiveTest, PostiveRange) {29 std::cout << "-- Testing for FE_TONEAREST in range [0x" << std::hex30 << POS_START << ", 0x" << POS_STOP << ") --" << std::dec31 << std::endl;32 test_full_range(mpfr::RoundingMode::Nearest, POS_START, POS_STOP);33}34 35// Range: [-Inf, 0];36static constexpr uint32_t NEG_START = 0x8000'0000U;37static constexpr uint32_t NEG_STOP = 0xff80'0000U;38 39TEST_F(LlvmLibcCosfExhaustiveTest, NegativeRange) {40 std::cout << "-- Testing for FE_TONEAREST in range [0x" << std::hex41 << NEG_START << ", 0x" << NEG_STOP << ") --" << std::dec42 << std::endl;43 test_full_range(mpfr::RoundingMode::Nearest, NEG_START, NEG_STOP);44}45