xref: /llvm-project/libc/test/src/math/exhaustive/fmodf16_test.cpp (revision ef05b0322307318eb806c0bd4cdcdae9e31d477b)
1*ef05b032SOverMighty //===-- Exhaustive test for fmodf16 ---------------------------------------===//
2*ef05b032SOverMighty //
3*ef05b032SOverMighty // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*ef05b032SOverMighty // See https://llvm.org/LICENSE.txt for license information.
5*ef05b032SOverMighty // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*ef05b032SOverMighty //
7*ef05b032SOverMighty //===----------------------------------------------------------------------===//
8*ef05b032SOverMighty 
9*ef05b032SOverMighty #include "exhaustive_test.h"
10*ef05b032SOverMighty #include "src/math/fmodf16.h"
11*ef05b032SOverMighty #include "utils/MPFRWrapper/MPFRUtils.h"
12*ef05b032SOverMighty 
13*ef05b032SOverMighty namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
14*ef05b032SOverMighty 
15*ef05b032SOverMighty using LlvmLibcFmodf16ExhaustiveTest =
16*ef05b032SOverMighty     LlvmLibcBinaryOpExhaustiveMathTest<float16, mpfr::Operation::Fmod,
17*ef05b032SOverMighty                                        LIBC_NAMESPACE::fmodf16>;
18*ef05b032SOverMighty 
19*ef05b032SOverMighty // Range: [0, Inf];
20*ef05b032SOverMighty static constexpr uint16_t POS_START = 0x0000U;
21*ef05b032SOverMighty static constexpr uint16_t POS_STOP = 0x7c00U;
22*ef05b032SOverMighty 
23*ef05b032SOverMighty // Range: [-Inf, 0];
24*ef05b032SOverMighty static constexpr uint16_t NEG_START = 0x8000U;
25*ef05b032SOverMighty static constexpr uint16_t NEG_STOP = 0xfc00U;
26*ef05b032SOverMighty 
TEST_F(LlvmLibcFmodf16ExhaustiveTest,PostivePositiveRange)27*ef05b032SOverMighty TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostivePositiveRange) {
28*ef05b032SOverMighty   test_full_range_all_roundings(POS_START, POS_STOP, POS_START, POS_STOP);
29*ef05b032SOverMighty }
30*ef05b032SOverMighty 
TEST_F(LlvmLibcFmodf16ExhaustiveTest,PostiveNegativeRange)31*ef05b032SOverMighty TEST_F(LlvmLibcFmodf16ExhaustiveTest, PostiveNegativeRange) {
32*ef05b032SOverMighty   test_full_range_all_roundings(POS_START, POS_STOP, NEG_START, NEG_STOP);
33*ef05b032SOverMighty }
34*ef05b032SOverMighty 
TEST_F(LlvmLibcFmodf16ExhaustiveTest,NegativePositiveRange)35*ef05b032SOverMighty TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativePositiveRange) {
36*ef05b032SOverMighty   test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
37*ef05b032SOverMighty }
38*ef05b032SOverMighty 
TEST_F(LlvmLibcFmodf16ExhaustiveTest,NegativeNegativeRange)39*ef05b032SOverMighty TEST_F(LlvmLibcFmodf16ExhaustiveTest, NegativeNegativeRange) {
40*ef05b032SOverMighty   test_full_range_all_roundings(NEG_START, NEG_STOP, POS_START, POS_STOP);
41*ef05b032SOverMighty }
42