[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / libc / test / include / IsZeroTest.h
blob83871963cd212528dd69db90e2d88dbe775a2c3b
1 //===-- Utility class to test the iszero macro -----------------*- 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 #ifndef LLVM_LIBC_TEST_INCLUDE_MATH_ISZERO_H
10 #define LLVM_LIBC_TEST_INCLUDE_MATH_ISZERO_H
12 #include "test/UnitTest/FPMatcher.h"
13 #include "test/UnitTest/Test.h"
15 #include "include/llvm-libc-macros/math-function-macros.h"
17 template <typename T> class IsZeroTest : public LIBC_NAMESPACE::testing::Test {
18 DECLARE_SPECIAL_CONSTANTS(T)
20 public:
21 typedef bool (*IsZeroFunc)(T);
23 void testSpecialNumbers(IsZeroFunc func) {
24 EXPECT_FALSE(func(inf));
25 EXPECT_FALSE(func(neg_inf));
26 EXPECT_TRUE(func(zero));
27 EXPECT_TRUE(func(neg_zero));
31 #define LIST_ISZERO_TESTS(T, func) \
32 using LlvmLibcIsZeroTest = IsZeroTest<T>; \
33 TEST_F(LlvmLibcIsZeroTest, SpecialNumbers) { \
34 auto iszero_func = [](T x) { return func(x); }; \
35 testSpecialNumbers(iszero_func); \
38 #endif // LLVM_LIBC_TEST_INCLUDE_MATH_ISZERO_H