18ff96eb1SOverMighty //===-- Utility class to test different flavors of nextdown -----*- C++ -*-===// 28ff96eb1SOverMighty // 38ff96eb1SOverMighty // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 48ff96eb1SOverMighty // See https://llvm.org/LICENSE.txt for license information. 58ff96eb1SOverMighty // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 68ff96eb1SOverMighty // 78ff96eb1SOverMighty //===----------------------------------------------------------------------===// 88ff96eb1SOverMighty 98ff96eb1SOverMighty #ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H 108ff96eb1SOverMighty #define LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H 118ff96eb1SOverMighty 12*837dab96SRoland McGrath #include "test/UnitTest/FEnvSafeTest.h" 138ff96eb1SOverMighty #include "test/UnitTest/FPMatcher.h" 148ff96eb1SOverMighty #include "test/UnitTest/Test.h" 158ff96eb1SOverMighty 168ff96eb1SOverMighty template <typename T> 17*837dab96SRoland McGrath class NextDownTestTemplate : public LIBC_NAMESPACE::testing::FEnvSafeTest { 188ff96eb1SOverMighty 198ff96eb1SOverMighty DECLARE_SPECIAL_CONSTANTS(T) 208ff96eb1SOverMighty 218ff96eb1SOverMighty public: 228ff96eb1SOverMighty typedef T (*NextDownFunc)(T); 238ff96eb1SOverMighty testNaN(NextDownFunc func)248ff96eb1SOverMighty void testNaN(NextDownFunc func) { ASSERT_FP_EQ(func(aNaN), aNaN); } 258ff96eb1SOverMighty testBoundaries(NextDownFunc func)268ff96eb1SOverMighty void testBoundaries(NextDownFunc func) { 278ff96eb1SOverMighty ASSERT_FP_EQ(zero, func(min_denormal)); 288ff96eb1SOverMighty 298ff96eb1SOverMighty ASSERT_FP_EQ(neg_min_denormal, func(zero)); 308ff96eb1SOverMighty ASSERT_FP_EQ(neg_min_denormal, func(neg_zero)); 318ff96eb1SOverMighty 328ff96eb1SOverMighty ASSERT_FP_EQ(neg_max_normal, func(neg_max_normal)); 338ff96eb1SOverMighty ASSERT_FP_EQ(neg_inf, func(neg_inf)); 348ff96eb1SOverMighty 358ff96eb1SOverMighty ASSERT_FP_EQ(max_normal, func(inf)); 368ff96eb1SOverMighty } 378ff96eb1SOverMighty }; 388ff96eb1SOverMighty 398ff96eb1SOverMighty #define LIST_NEXTDOWN_TESTS(T, func) \ 408ff96eb1SOverMighty using LlvmLibcNextDownTest = NextDownTestTemplate<T>; \ 418ff96eb1SOverMighty TEST_F(LlvmLibcNextDownTest, TestNaN) { testNaN(&func); } \ 428ff96eb1SOverMighty TEST_F(LlvmLibcNextDownTest, TestBoundaries) { testBoundaries(&func); } 438ff96eb1SOverMighty 448ff96eb1SOverMighty #endif // LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H 45