| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===-- Utility class to test different flavors of nextdown -----*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H | ||
| #define LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H | ||
|
|
||
| #include "test/UnitTest/FPMatcher.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| template <typename T> | ||
| class NextDownTestTemplate : public LIBC_NAMESPACE::testing::Test { | ||
|
|
||
| DECLARE_SPECIAL_CONSTANTS(T) | ||
|
|
||
| public: | ||
| typedef T (*NextDownFunc)(T); | ||
|
|
||
| void testNaN(NextDownFunc func) { ASSERT_FP_EQ(func(aNaN), aNaN); } | ||
|
|
||
| void testBoundaries(NextDownFunc func) { | ||
| ASSERT_FP_EQ(zero, func(min_denormal)); | ||
|
|
||
| ASSERT_FP_EQ(neg_min_denormal, func(zero)); | ||
| ASSERT_FP_EQ(neg_min_denormal, func(neg_zero)); | ||
|
|
||
| ASSERT_FP_EQ(neg_max_normal, func(neg_max_normal)); | ||
| ASSERT_FP_EQ(neg_inf, func(neg_inf)); | ||
|
|
||
| ASSERT_FP_EQ(max_normal, func(inf)); | ||
| } | ||
| }; | ||
|
|
||
| #define LIST_NEXTDOWN_TESTS(T, func) \ | ||
| using LlvmLibcNextDownTest = NextDownTestTemplate<T>; \ | ||
| TEST_F(LlvmLibcNextDownTest, TestNaN) { testNaN(&func); } \ | ||
| TEST_F(LlvmLibcNextDownTest, TestBoundaries) { testBoundaries(&func); } | ||
|
|
||
| #endif // LLVM_LIBC_TEST_SRC_MATH_NEXTDOWNTEST_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===-- Utility class to test different flavors of nextup -------*- C++ -*-===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H | ||
| #define LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H | ||
|
|
||
| #include "test/UnitTest/FPMatcher.h" | ||
| #include "test/UnitTest/Test.h" | ||
|
|
||
| template <typename T> | ||
| class NextUpTestTemplate : public LIBC_NAMESPACE::testing::Test { | ||
|
|
||
| DECLARE_SPECIAL_CONSTANTS(T) | ||
|
|
||
| public: | ||
| typedef T (*NextUpFunc)(T); | ||
|
|
||
| void testNaN(NextUpFunc func) { ASSERT_FP_EQ(func(aNaN), aNaN); } | ||
|
|
||
| void testBoundaries(NextUpFunc func) { | ||
| ASSERT_FP_EQ(neg_zero, func(neg_min_denormal)); | ||
|
|
||
| ASSERT_FP_EQ(min_denormal, func(zero)); | ||
| ASSERT_FP_EQ(min_denormal, func(neg_zero)); | ||
|
|
||
| ASSERT_FP_EQ(max_normal, func(max_normal)); | ||
| ASSERT_FP_EQ(inf, func(inf)); | ||
|
|
||
| ASSERT_FP_EQ(neg_max_normal, func(neg_inf)); | ||
| } | ||
| }; | ||
|
|
||
| #define LIST_NEXTUP_TESTS(T, func) \ | ||
| using LlvmLibcNextUpTest = NextUpTestTemplate<T>; \ | ||
| TEST_F(LlvmLibcNextUpTest, TestNaN) { testNaN(&func); } \ | ||
| TEST_F(LlvmLibcNextUpTest, TestBoundaries) { testBoundaries(&func); } | ||
|
|
||
| #endif // LLVM_LIBC_TEST_SRC_MATH_NEXTUPTEST_H |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextdown --------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextDownTest.h" | ||
|
|
||
| #include "src/math/nextdown.h" | ||
|
|
||
| LIST_NEXTDOWN_TESTS(double, LIBC_NAMESPACE::nextdown) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextdownf128 ----------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextDownTest.h" | ||
|
|
||
| #include "src/math/nextdownf128.h" | ||
|
|
||
| LIST_NEXTDOWN_TESTS(float128, LIBC_NAMESPACE::nextdownf128) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextdownf -------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextDownTest.h" | ||
|
|
||
| #include "src/math/nextdownf.h" | ||
|
|
||
| LIST_NEXTDOWN_TESTS(float, LIBC_NAMESPACE::nextdownf) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextup ----------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextUpTest.h" | ||
|
|
||
| #include "src/math/nextup.h" | ||
|
|
||
| LIST_NEXTUP_TESTS(double, LIBC_NAMESPACE::nextup) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextupf128 ------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextUpTest.h" | ||
|
|
||
| #include "src/math/nextupf128.h" | ||
|
|
||
| LIST_NEXTUP_TESTS(float128, LIBC_NAMESPACE::nextupf128) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| //===-- Unittests for nextupf ---------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #include "NextUpTest.h" | ||
|
|
||
| #include "src/math/nextupf.h" | ||
|
|
||
| LIST_NEXTUP_TESTS(float, LIBC_NAMESPACE::nextupf) |