Skip to content

Commit 1dfefaf

Browse files
committed
Add same type tests
1 parent 270218e commit 1dfefaf

25 files changed

+205
-37
lines changed

libc/test/src/math/AddTest.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ class AddTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6666
}
6767
};
6868

69-
#define LIST_ADD_TESTS(OutType, InType, func) \
70-
using LlvmLibcAddTest = AddTest<OutType, InType>; \
71-
TEST_F(LlvmLibcAddTest, SubnormalRange) { test_subnormal_range(&func); } \
72-
TEST_F(LlvmLibcAddTest, NormalRange) { test_normal_range(&func); }
69+
#define LIST_ADD_TESTS(suffix, OutType, InType, func) \
70+
using LlvmLibcAddTest##suffix = AddTest<OutType, InType>; \
71+
TEST_F(LlvmLibcAddTest##suffix, SubnormalRange) { \
72+
test_subnormal_range(&func); \
73+
} \
74+
TEST_F(LlvmLibcAddTest##suffix, NormalRange) { test_normal_range(&func); }
7375

7476
#endif // LLVM_LIBC_TEST_SRC_MATH_ADDTEST_H

libc/test/src/math/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,33 @@ add_fp_unittest(
27672767
libc.src.stdlib.srand
27682768
)
27692769

2770+
add_fp_unittest(
2771+
add_same_type_test
2772+
NEED_MPFR
2773+
SUITE
2774+
libc-math-unittests
2775+
SRCS
2776+
add_same_type_test.cpp
2777+
HDRS
2778+
AddTest.h
2779+
DEPENDS
2780+
libc.src.__support.FPUtil.generic.add_or_sub
2781+
libc.src.__support.macros.properties.types
2782+
)
2783+
2784+
add_fp_unittest(
2785+
sub_same_type_test
2786+
NEED_MPFR
2787+
SUITE
2788+
libc-math-unittests
2789+
SRCS
2790+
sub_same_type_test.cpp
2791+
HDRS
2792+
SubTest.h
2793+
DEPENDS
2794+
libc.src.__support.FPUtil.generic.add_or_sub
2795+
libc.src.__support.macros.properties.types
2796+
)
27702797

27712798
add_subdirectory(generic)
27722799
add_subdirectory(smoke)

libc/test/src/math/SubTest.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ class SubTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
6666
}
6767
};
6868

69-
#define LIST_SUB_TESTS(OutType, InType, func) \
70-
using LlvmLibcSubTest = SubTest<OutType, InType>; \
71-
TEST_F(LlvmLibcSubTest, SubnormalRange) { test_subnormal_range(&func); } \
72-
TEST_F(LlvmLibcSubTest, NormalRange) { test_normal_range(&func); }
69+
#define LIST_SUB_TESTS(suffix, OutType, InType, func) \
70+
using LlvmLibcSubTest##suffix = SubTest<OutType, InType>; \
71+
TEST_F(LlvmLibcSubTest##suffix, SubnormalRange) { \
72+
test_subnormal_range(&func); \
73+
} \
74+
TEST_F(LlvmLibcSubTest##suffix, NormalRange) { test_normal_range(&func); }
7375

7476
#endif // LLVM_LIBC_TEST_SRC_MATH_SUBTEST_H
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===-- Unittests for fputil::generic::add --------------------------------===//
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+
//===----------------------------------------------------------------------===//
8+
9+
#include "AddTest.h"
10+
11+
#include "src/__support/FPUtil/generic/add_sub.h"
12+
#include "src/__support/macros/properties/types.h"
13+
14+
#define ADD_FUNC(T) (LIBC_NAMESPACE::fputil::generic::add<T, T>)
15+
16+
LIST_ADD_TESTS(Double, double, double, ADD_FUNC(double))
17+
LIST_ADD_TESTS(Float, float, float, ADD_FUNC(float))
18+
LIST_ADD_TESTS(LongDouble, long double, long double, ADD_FUNC(long double))
19+
#ifdef LIBC_TYPES_HAS_FLOAT16
20+
LIST_ADD_TESTS(Float16, float16, float16, ADD_FUNC(float16))
21+
#endif
22+
#ifdef LIBC_TYPES_HAS_FLOAT128
23+
LIST_ADD_TESTS(Float128, float128, float128, ADD_FUNC(float128))
24+
#endif

libc/test/src/math/daddl_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/daddl.h"
1212

13-
LIST_ADD_TESTS(double, long double, LIBC_NAMESPACE::daddl)
13+
LIST_ADD_TESTS(DoubleLongDouble, double, long double, LIBC_NAMESPACE::daddl)

libc/test/src/math/f16add_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/f16add.h"
1212

13-
LIST_ADD_TESTS(float16, double, LIBC_NAMESPACE::f16add)
13+
LIST_ADD_TESTS(Float16Double, float16, double, LIBC_NAMESPACE::f16add)

libc/test/src/math/f16addf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/f16addf.h"
1212

13-
LIST_ADD_TESTS(float16, float, LIBC_NAMESPACE::f16addf)
13+
LIST_ADD_TESTS(Float16Float, float16, float, LIBC_NAMESPACE::f16addf)

libc/test/src/math/f16addl_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/f16addl.h"
1212

13-
LIST_ADD_TESTS(float16, long double, LIBC_NAMESPACE::f16addl)
13+
LIST_ADD_TESTS(Float16LongDouble, float16, long double, LIBC_NAMESPACE::f16addl)

libc/test/src/math/fadd_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/fadd.h"
1212

13-
LIST_ADD_TESTS(float, double, LIBC_NAMESPACE::fadd)
13+
LIST_ADD_TESTS(FloatDouble, float, double, LIBC_NAMESPACE::fadd)

libc/test/src/math/faddl_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
#include "src/math/faddl.h"
1212

13-
LIST_ADD_TESTS(float, long double, LIBC_NAMESPACE::faddl)
13+
LIST_ADD_TESTS(FloatLongDouble, float, long double, LIBC_NAMESPACE::faddl)

0 commit comments

Comments
 (0)