1 //===-- Utility class to test the isnormal macro ---------------*- 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 #ifndef LLVM_LIBC_TEST_INCLUDE_MATH_ISNORMAL_H
10 #define LLVM_LIBC_TEST_INCLUDE_MATH_ISNORMAL_H
12 #include "test/UnitTest/FPMatcher.h"
13 #include "test/UnitTest/Test.h"
15 #include "include/llvm-libc-macros/math-function-macros.h"
18 class IsNormalTest
: public LIBC_NAMESPACE::testing::Test
{
19 DECLARE_SPECIAL_CONSTANTS(T
)
22 typedef int (*IsNormalFunc
)(T
);
24 void testSpecialNumbers(IsNormalFunc func
) {
25 EXPECT_EQ(func(aNaN
), 0);
26 EXPECT_EQ(func(neg_aNaN
), 0);
27 EXPECT_EQ(func(sNaN
), 0);
28 EXPECT_EQ(func(neg_sNaN
), 0);
29 EXPECT_EQ(func(inf
), 0);
30 EXPECT_EQ(func(neg_inf
), 0);
31 EXPECT_EQ(func(min_normal
), 1);
32 EXPECT_EQ(func(max_normal
), 1);
33 EXPECT_EQ(func(neg_max_normal
), 1);
34 EXPECT_EQ(func(min_denormal
), 0);
35 EXPECT_EQ(func(neg_min_denormal
), 0);
36 EXPECT_EQ(func(max_denormal
), 0);
37 EXPECT_EQ(func(zero
), 0);
38 EXPECT_EQ(func(neg_zero
), 0);
42 #define LIST_ISNORMAL_TESTS(T, func) \
43 using LlvmLibcIsNormalTest = IsNormalTest<T>; \
44 TEST_F(LlvmLibcIsNormalTest, SpecialNumbers) { \
45 auto isnormal_func = [](T x) { return func(x); }; \
46 testSpecialNumbers(isnormal_func); \
49 #endif // LLVM_LIBC_TEST_INCLUDE_MATH_ISNORMAL_H