[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / libc / test / src / math / exhaustive / exhaustive_test.h
blob9f9b6bfc1cf5c6d32073fc1b9853fd977dd2eca6
1 //===-- Exhaustive test template for math functions -------------*- C++ -*-===//
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-exception
6 //
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);
23 static_assert(
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;