brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d0686d4 Raw
38 lines · c
1//===-- Utility class to test the signbit macro [f|l] -----------*- 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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_TEST_INCLUDE_MATH_SIGNBIT_H10#define LLVM_LIBC_TEST_INCLUDE_MATH_SIGNBIT_H11 12#include "test/UnitTest/FPMatcher.h"13#include "test/UnitTest/Test.h"14 15#include "include/llvm-libc-macros/math-function-macros.h"16 17template <typename T> class SignbitTest : public LIBC_NAMESPACE::testing::Test {18 19  DECLARE_SPECIAL_CONSTANTS(T)20 21public:22  typedef int (*SignbitFunc)(T);23 24  void testSpecialNumbers(SignbitFunc func) {25    EXPECT_EQ(func(1), 0);26    EXPECT_NE(func(-1), 0);27  }28};29 30#define LIST_SIGNBIT_TESTS(T, func)                                            \31  using LlvmLibcSignbitTest = SignbitTest<T>;                                  \32  TEST_F(LlvmLibcSignbitTest, SpecialNumbers) {                                \33    auto signbit_func = [](T x) { return func(x); };                           \34    testSpecialNumbers(signbit_func);                                          \35  }36 37#endif // LLVM_LIBC_TEST_INCLUDE_MATH_SIGNBIT_H38