1 //===-- Exhaustive test template for math functions -------------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #include "src/__support/CPP/type_traits.h"
10 #include "src/__support/FPUtil/FPBits.h"
11 #include "test/UnitTest/Test.h"
12 #include "utils/MPFRWrapper/MPFRUtils.h"
14 // To test exhaustively for inputs in the range [start, stop) in parallel:
15 // 1. Inherit from LlvmLibcExhaustiveTest class
16 // 2. Overide the test method: void check(T, T, RoundingMode)
17 // 4. Call: test_full_range(start, stop, nthreads, rounding)
18 namespace mpfr
= __llvm_libc::testing::mpfr
;
20 template <typename T
, typename FloatType
= float>
21 struct LlvmLibcExhaustiveTest
: public __llvm_libc::testing::Test
{
22 static constexpr T increment
= (1 << 20);
24 __llvm_libc::cpp::is_same_v
<
25 T
, typename
__llvm_libc::fputil::FPBits
<FloatType
>::UIntType
>,
26 "Types are not consistent");
27 // Break [start, stop) into `nthreads` subintervals and apply *check to each
28 // subinterval in parallel.
29 void test_full_range(T start
, T stop
, mpfr::RoundingMode rounding
);
31 virtual bool check(T start
, T stop
, mpfr::RoundingMode rounding
) = 0;