summaryrefslogtreecommitdiff
path: root/libc/test/src/complex
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
committerMichael Kruse <llvm-project@meinersbur.de>2025-01-03 10:22:51 +0100
commit38500d63e14ce340236840f60d356cdefb56a52c (patch)
tree17edbec446ce9b50d2f215a483b83afb293a635d /libc/test/src/complex
parent1a3d5daaef7a6a63448a497da3eff7fc9e23df26 (diff)
parent27f30029741ecf023baece7b3dde1ff9011ffefc (diff)
Merge branch 'main' into users/meinersbur/flang_runtime_split-headersusers/meinersbur/flang_runtime_split-headers
Diffstat (limited to 'libc/test/src/complex')
-rw-r--r--libc/test/src/complex/CImagTest.h11
-rw-r--r--libc/test/src/complex/CMakeLists.txt120
-rw-r--r--libc/test/src/complex/CRealTest.h10
-rw-r--r--libc/test/src/complex/ConjTest.h131
-rw-r--r--libc/test/src/complex/CprojTest.h131
-rw-r--r--libc/test/src/complex/cimagf128_test.cpp4
-rw-r--r--libc/test/src/complex/cimagf16_test.cpp4
-rw-r--r--libc/test/src/complex/conj_test.cpp13
-rw-r--r--libc/test/src/complex/conjf128_test.cpp13
-rw-r--r--libc/test/src/complex/conjf16_test.cpp13
-rw-r--r--libc/test/src/complex/conjf_test.cpp13
-rw-r--r--libc/test/src/complex/conjl_test.cpp13
-rw-r--r--libc/test/src/complex/cproj_test.cpp13
-rw-r--r--libc/test/src/complex/cprojf128_test.cpp13
-rw-r--r--libc/test/src/complex/cprojf16_test.cpp13
-rw-r--r--libc/test/src/complex/cprojf_test.cpp13
-rw-r--r--libc/test/src/complex/cprojl_test.cpp13
-rw-r--r--libc/test/src/complex/crealf128_test.cpp4
-rw-r--r--libc/test/src/complex/crealf16_test.cpp4
19 files changed, 528 insertions, 21 deletions
diff --git a/libc/test/src/complex/CImagTest.h b/libc/test/src/complex/CImagTest.h
index 6d2f93500266..408460d97dfc 100644
--- a/libc/test/src/complex/CImagTest.h
+++ b/libc/test/src/complex/CImagTest.h
@@ -38,9 +38,14 @@ public:
neg_min_denormal);
EXPECT_FP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)), max_denormal);
EXPECT_FP_EQ(func(CFPT(121.121 + zero * 1.0i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero);
- EXPECT_FP_EQ(func(CFPT(zero + neg_zero * 1.0i)), neg_zero);
+ EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), -0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0i)), -0.0);
}
void testRoundedNumbers(CImagFunc func) {
diff --git a/libc/test/src/complex/CMakeLists.txt b/libc/test/src/complex/CMakeLists.txt
index 8f49e6d79e17..d6b62e4686a2 100644
--- a/libc/test/src/complex/CMakeLists.txt
+++ b/libc/test/src/complex/CMakeLists.txt
@@ -1,6 +1,126 @@
add_custom_target(libc-complex-unittests)
add_libc_test(
+ conj_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conj_test.cpp
+ DEPENDS
+ libc.src.complex.conj
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf_test.cpp
+ DEPENDS
+ libc.src.complex.conjf
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjl_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjl_test.cpp
+ DEPENDS
+ libc.src.complex.conjl
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf16_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf16_test.cpp
+ DEPENDS
+ libc.src.complex.conjf16
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ conjf128_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ conjf128_test.cpp
+ DEPENDS
+ libc.src.complex.conjf128
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ cproj_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ cproj_test.cpp
+ DEPENDS
+ libc.src.complex.cproj
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ cprojf_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ cprojf_test.cpp
+ DEPENDS
+ libc.src.complex.cprojf
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ cprojl_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ cprojl_test.cpp
+ DEPENDS
+ libc.src.complex.cprojl
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ cprojf16_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ cprojf16_test.cpp
+ DEPENDS
+ libc.src.complex.cprojf16
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
+ cprojf128_test
+ SUITE
+ libc-complex-unittests
+ SRCS
+ cprojf128_test.cpp
+ DEPENDS
+ libc.src.complex.cprojf128
+ LINK_LIBRARIES
+ LibcFPTestHelpers
+)
+
+add_libc_test(
creal_test
SUITE
libc-complex-unittests
diff --git a/libc/test/src/complex/CRealTest.h b/libc/test/src/complex/CRealTest.h
index a25555b506e2..80eafc9975f4 100644
--- a/libc/test/src/complex/CRealTest.h
+++ b/libc/test/src/complex/CRealTest.h
@@ -37,8 +37,14 @@ public:
EXPECT_FP_EQ(func(CFPT(neg_min_denormal + 781.134i)), neg_min_denormal);
EXPECT_FP_EQ(func(CFPT(max_denormal + 1241.112i)), max_denormal);
EXPECT_FP_EQ(func(CFPT(zero + 121.121i)), zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + neg_zero * 1.0i)), neg_zero);
- EXPECT_FP_EQ(func(CFPT(neg_zero + zero * 1.0i)), zero);
+ EXPECT_FP_EQ(func(CFPT(0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 + 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0 - 0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0 - 0.0i)), -0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0)), -0.0);
+ EXPECT_FP_EQ(func(CFPT(0.0i)), 0.0);
+ EXPECT_FP_EQ(func(CFPT(-0.0i)), -0.0);
}
void testRoundedNumbers(CRealFunc func) {
diff --git a/libc/test/src/complex/ConjTest.h b/libc/test/src/complex/ConjTest.h
new file mode 100644
index 000000000000..da4fb4fd137c
--- /dev/null
+++ b/libc/test/src/complex/ConjTest.h
@@ -0,0 +1,131 @@
+//===-- Utility class to test different flavors of conj ---------*- 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_COMPLEX_CONJTEST_H
+#define LLVM_LIBC_TEST_SRC_COMPLEX_CONJTEST_H
+
+#include "test/UnitTest/FEnvSafeTest.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "hdr/math_macros.h"
+
+template <typename CFPT, typename FPT>
+class ConjTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
+
+ DECLARE_SPECIAL_CONSTANTS(FPT)
+
+public:
+ typedef CFPT (*ConjFunc)(CFPT);
+
+ void testSpecialNumbers(ConjFunc func) {
+ EXPECT_CFP_EQ(func(CFPT(aNaN + 67.123i)), CFPT(aNaN - 67.123i));
+ EXPECT_CFP_EQ(func(CFPT(neg_aNaN + 78.319i)), CFPT(neg_aNaN - 78.319i));
+ EXPECT_CFP_EQ(func(CFPT(sNaN + 7813.131i)), CFPT(sNaN - 7813.131i));
+ EXPECT_CFP_EQ(func(CFPT(neg_sNaN + 7824.152i)), CFPT(neg_sNaN - 7824.152i));
+ EXPECT_CFP_EQ(func(CFPT(inf + 9024.2442i)), CFPT(inf - 9024.2442i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf + 8923.124i)), CFPT(neg_inf - 8923.124i));
+ EXPECT_CFP_EQ(func(CFPT(min_normal + 782.124i)),
+ CFPT(min_normal - 782.124i));
+ EXPECT_CFP_EQ(func(CFPT(max_normal + 2141.2352i)),
+ CFPT(max_normal - 2141.2352i));
+ EXPECT_CFP_EQ(func(CFPT(neg_max_normal + 341.134i)),
+ CFPT(neg_max_normal - 341.134i));
+ EXPECT_CFP_EQ(func(CFPT(min_denormal + 781.142i)),
+ CFPT(min_denormal - 781.142i));
+ EXPECT_CFP_EQ(func(CFPT(neg_min_denormal + 781.134i)),
+ CFPT(neg_min_denormal - 781.134i));
+ EXPECT_CFP_EQ(func(CFPT(max_denormal + 1241.112i)),
+ CFPT(max_denormal - 1241.112i));
+ EXPECT_CFP_EQ(func(CFPT(zero + 121.121i)), CFPT(zero - 121.121i));
+ EXPECT_CFP_EQ(func(CFPT(67.123 + aNaN * 1.0i)), CFPT(67.123 - aNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(78.319 + neg_aNaN * 1.0i)),
+ CFPT(78.319 - neg_aNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(7813.131 + sNaN * 1.0i)),
+ CFPT(7813.131 - sNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(7824.152 + neg_sNaN * 1.0i)),
+ CFPT(7824.152 - neg_sNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(9024.2442 + inf * 1.0i)),
+ CFPT(9024.2442 - inf * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(8923.124 + neg_inf * 1.0i)),
+ CFPT(8923.124 - neg_inf * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(782.124 + min_normal * 1.0i)),
+ CFPT(782.124 - min_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(2141.2352 + max_normal * 1.0i)),
+ CFPT(2141.2352 - max_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(341.134 + neg_max_normal * 1.0i)),
+ CFPT(341.134 - neg_max_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(781.142 + min_denormal * 1.0i)),
+ CFPT(781.142 - min_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(781.134 + neg_min_denormal * 1.0i)),
+ CFPT(781.134 - neg_min_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)),
+ CFPT(1241.112 - max_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(121.121 + zero * 1.0i)),
+ CFPT(121.121 - zero * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0 - 0.0i)), CFPT(0.0 + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0 + 0.0i)), CFPT(0.0 - 0.0i));
+ // This test passes because the conjugate of -0.0 - 0.0i is CMPLX(-0.0, 0.0)
+ // which cannot be represented as -0.0 + 0.0i because -0.0 + 0.0i is
+ // actually CMPLX(-0.0, 0.0) + CMPLX(0.0, 0.0) = 0.0 + 0.0i so to represent
+ // CMPLX(-0.0, 0.0), we use -0.0
+ EXPECT_CFP_EQ(func(CFPT(-0.0 - 0.0i)), CFPT(-0.0));
+ // This test passes because -0.0 + 0.0i is actually
+ // CMPLX(-0.0, 0.0) + CMPLX(0.0, 0.0) = CMPLX(-0.0 + 0.0, 0.0) = 0.0 + 0.0i
+ EXPECT_CFP_EQ(func(CFPT(-0.0 + 0.0i)), CFPT(0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0)), CFPT(0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(-0.0)), CFPT(-0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0i)), CFPT(0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(-0.0i)), CFPT(-0.0));
+ }
+
+ void testRoundedNumbers(ConjFunc func) {
+ EXPECT_CFP_EQ(func((CFPT)(4523.1413 + 12413.1414i)),
+ CFPT(4523.1413 - 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(-4523.1413 + 12413.1414i)),
+ CFPT(-4523.1413 - 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(4523.1413 - 12413.1414i)),
+ CFPT(4523.1413 + 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(-4523.1413 - 12413.1414i)),
+ CFPT(-4523.1413 + 12413.1414i));
+
+ EXPECT_CFP_EQ(func((CFPT)(3210.5678 + 9876.5432i)),
+ CFPT(3210.5678 - 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(-3210.5678 + 9876.5432i)),
+ CFPT(-3210.5678 - 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(3210.5678 - 9876.5432i)),
+ CFPT(3210.5678 + 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(-3210.5678 - 9876.5432i)),
+ CFPT(-3210.5678 + 9876.5432i));
+
+ EXPECT_CFP_EQ(func((CFPT)(1234.4321 + 4321.1234i)),
+ CFPT(1234.4321 - 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(-1234.4321 + 4321.1234i)),
+ CFPT(-1234.4321 - 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(1234.4321 - 4321.1234i)),
+ CFPT(1234.4321 + 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(-1234.4321 - 4321.1234i)),
+ CFPT(-1234.4321 + 4321.1234i));
+
+ EXPECT_CFP_EQ(func((CFPT)(6789.1234 + 8765.6789i)),
+ CFPT(6789.1234 - 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(-6789.1234 + 8765.6789i)),
+ CFPT(-6789.1234 - 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(6789.1234 - 8765.6789i)),
+ CFPT(6789.1234 + 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(-6789.1234 - 8765.6789i)),
+ CFPT(-6789.1234 + 8765.6789i));
+ }
+};
+
+#define LIST_CONJ_TESTS(U, T, func) \
+ using LlvmLibcConjTest = ConjTest<U, T>; \
+ TEST_F(LlvmLibcConjTest, SpecialNumbers) { testSpecialNumbers(&func); } \
+ TEST_F(LlvmLibcConjTest, RoundedNumbers) { testRoundedNumbers(&func); }
+
+#endif // LLVM_LIBC_TEST_SRC_COMPLEX_CONJTEST_H
diff --git a/libc/test/src/complex/CprojTest.h b/libc/test/src/complex/CprojTest.h
new file mode 100644
index 000000000000..4e2f6cc58a5a
--- /dev/null
+++ b/libc/test/src/complex/CprojTest.h
@@ -0,0 +1,131 @@
+//===-- Utility class to test different flavors of cproj --------*- 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_COMPLEX_CPROJTEST_H
+#define LLVM_LIBC_TEST_SRC_COMPLEX_CPROJTEST_H
+
+#include "test/UnitTest/FEnvSafeTest.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+#include "hdr/math_macros.h"
+
+template <typename CFPT, typename FPT>
+class CprojTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
+
+ DECLARE_SPECIAL_CONSTANTS(FPT)
+
+public:
+ typedef CFPT (*CprojFunc)(CFPT);
+
+ void testSpecialNumbers(CprojFunc func) {
+ EXPECT_CFP_EQ(func(CFPT(inf + 9024.2442i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(inf - 9024.2442i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf + 8923.124i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf - 8923.124i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(9024.2442 + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(9024.2442 + neg_inf * 1.0i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(inf + neg_inf * 1.0i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(inf + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf + neg_inf * 1.0i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(neg_inf + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(aNaN + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(aNaN + neg_inf * 1.0i)), CFPT(inf - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(90.24 + inf * 1.0i)), CFPT(inf + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(89.12 + neg_inf * 1.0i)), CFPT(inf - 0.0i));
+
+ EXPECT_CFP_EQ(func(CFPT(aNaN + 67.123i)), CFPT(aNaN + 67.123i));
+ EXPECT_CFP_EQ(func(CFPT(neg_aNaN + 78.319i)), CFPT(neg_aNaN + 78.319i));
+ EXPECT_CFP_EQ(func(CFPT(sNaN + 7813.131i)), CFPT(sNaN + 7813.131i));
+ EXPECT_CFP_EQ(func(CFPT(neg_sNaN + 7824.152i)), CFPT(neg_sNaN + 7824.152i));
+ EXPECT_CFP_EQ(func(CFPT(min_normal + 782.124i)),
+ CFPT(min_normal + 782.124i));
+ EXPECT_CFP_EQ(func(CFPT(max_normal + 2141.2352i)),
+ CFPT(max_normal + 2141.2352i));
+ EXPECT_CFP_EQ(func(CFPT(neg_max_normal + 341.134i)),
+ CFPT(neg_max_normal + 341.134i));
+ EXPECT_CFP_EQ(func(CFPT(min_denormal + 781.142i)),
+ CFPT(min_denormal + 781.142i));
+ EXPECT_CFP_EQ(func(CFPT(neg_min_denormal + 781.134i)),
+ CFPT(neg_min_denormal + 781.134i));
+ EXPECT_CFP_EQ(func(CFPT(max_denormal + 1241.112i)),
+ CFPT(max_denormal + 1241.112i));
+ EXPECT_CFP_EQ(func(CFPT(zero + 121.121i)), CFPT(zero + 121.121i));
+ EXPECT_CFP_EQ(func(CFPT(67.123 + aNaN * 1.0i)), CFPT(67.123 + aNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(78.319 + neg_aNaN * 1.0i)),
+ CFPT(78.319 + neg_aNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(7813.131 + sNaN * 1.0i)),
+ CFPT(7813.131 + sNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(7824.152 + neg_sNaN * 1.0i)),
+ CFPT(7824.152 + neg_sNaN * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(782.124 + min_normal * 1.0i)),
+ CFPT(782.124 + min_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(2141.2352 + max_normal * 1.0i)),
+ CFPT(2141.2352 + max_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(341.134 + neg_max_normal * 1.0i)),
+ CFPT(341.134 + neg_max_normal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(781.142 + min_denormal * 1.0i)),
+ CFPT(781.142 + min_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(781.134 + neg_min_denormal * 1.0i)),
+ CFPT(781.134 + neg_min_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(1241.112 + max_denormal * 1.0i)),
+ CFPT(1241.112 + max_denormal * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(121.121 + zero * 1.0i)),
+ CFPT(121.121 + zero * 1.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0 - 0.0i)), CFPT(0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(0.0 + 0.0i)), CFPT(0.0 + 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(-0.0 - 0.0i)), CFPT(-0.0 - 0.0i));
+ EXPECT_CFP_EQ(func(CFPT(-0.0 + 0.0i)), CFPT(-0.0 + 0.0i));
+ }
+
+ void testRoundedNumbers(CprojFunc func) {
+ EXPECT_CFP_EQ(func((CFPT)(4523.1413 + 12413.1414i)),
+ CFPT(4523.1413 + 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(-4523.1413 + 12413.1414i)),
+ CFPT(-4523.1413 + 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(4523.1413 - 12413.1414i)),
+ CFPT(4523.1413 - 12413.1414i));
+ EXPECT_CFP_EQ(func((CFPT)(-4523.1413 - 12413.1414i)),
+ CFPT(-4523.1413 - 12413.1414i));
+
+ EXPECT_CFP_EQ(func((CFPT)(3210.5678 + 9876.5432i)),
+ CFPT(3210.5678 + 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(-3210.5678 + 9876.5432i)),
+ CFPT(-3210.5678 + 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(3210.5678 - 9876.5432i)),
+ CFPT(3210.5678 - 9876.5432i));
+ EXPECT_CFP_EQ(func((CFPT)(-3210.5678 - 9876.5432i)),
+ CFPT(-3210.5678 - 9876.5432i));
+
+ EXPECT_CFP_EQ(func((CFPT)(1234.4321 + 4321.1234i)),
+ CFPT(1234.4321 + 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(-1234.4321 + 4321.1234i)),
+ CFPT(-1234.4321 + 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(1234.4321 - 4321.1234i)),
+ CFPT(1234.4321 - 4321.1234i));
+ EXPECT_CFP_EQ(func((CFPT)(-1234.4321 - 4321.1234i)),
+ CFPT(-1234.4321 - 4321.1234i));
+
+ EXPECT_CFP_EQ(func((CFPT)(6789.1234 + 8765.6789i)),
+ CFPT(6789.1234 + 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(-6789.1234 + 8765.6789i)),
+ CFPT(-6789.1234 + 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(6789.1234 - 8765.6789i)),
+ CFPT(6789.1234 - 8765.6789i));
+ EXPECT_CFP_EQ(func((CFPT)(-6789.1234 - 8765.6789i)),
+ CFPT(-6789.1234 - 8765.6789i));
+ }
+};
+
+#define LIST_CPROJ_TESTS(U, T, func) \
+ using LlvmLibcCprojTest = CprojTest<U, T>; \
+ TEST_F(LlvmLibcCprojTest, SpecialNumbers) { testSpecialNumbers(&func); } \
+ TEST_F(LlvmLibcCprojTest, RoundedNumbers) { testRoundedNumbers(&func); }
+
+#endif // LLVM_LIBC_TEST_SRC_COMPLEX_CPROJTEST_H
diff --git a/libc/test/src/complex/cimagf128_test.cpp b/libc/test/src/complex/cimagf128_test.cpp
index 50ddc0ab0616..70ad0de3d38f 100644
--- a/libc/test/src/complex/cimagf128_test.cpp
+++ b/libc/test/src/complex/cimagf128_test.cpp
@@ -10,8 +10,4 @@
#include "src/complex/cimagf128.h"
-#if defined(LIBC_TYPES_HAS_CFLOAT128)
-
LIST_CIMAG_TESTS(cfloat128, float128, LIBC_NAMESPACE::cimagf128)
-
-#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/test/src/complex/cimagf16_test.cpp b/libc/test/src/complex/cimagf16_test.cpp
index 65a69787ddbd..3842381351ab 100644
--- a/libc/test/src/complex/cimagf16_test.cpp
+++ b/libc/test/src/complex/cimagf16_test.cpp
@@ -10,8 +10,4 @@
#include "src/complex/cimagf16.h"
-#if defined(LIBC_TYPES_HAS_CFLOAT16)
-
LIST_CIMAG_TESTS(cfloat16, float16, LIBC_NAMESPACE::cimagf16)
-
-#endif // LIBC_TYPES_HAS_CFLOAT16
diff --git a/libc/test/src/complex/conj_test.cpp b/libc/test/src/complex/conj_test.cpp
new file mode 100644
index 000000000000..97445fa06508
--- /dev/null
+++ b/libc/test/src/complex/conj_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for conj ------------------------------------------------===//
+//
+// 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 "ConjTest.h"
+
+#include "src/complex/conj.h"
+
+LIST_CONJ_TESTS(_Complex double, double, LIBC_NAMESPACE::conj)
diff --git a/libc/test/src/complex/conjf128_test.cpp b/libc/test/src/complex/conjf128_test.cpp
new file mode 100644
index 000000000000..4c2a72c6d39d
--- /dev/null
+++ b/libc/test/src/complex/conjf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for conjf128 --------------------------------------------===//
+//
+// 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 "ConjTest.h"
+
+#include "src/complex/conjf128.h"
+
+LIST_CONJ_TESTS(cfloat128, float128, LIBC_NAMESPACE::conjf128)
diff --git a/libc/test/src/complex/conjf16_test.cpp b/libc/test/src/complex/conjf16_test.cpp
new file mode 100644
index 000000000000..374f9ec3e624
--- /dev/null
+++ b/libc/test/src/complex/conjf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for conjf16 ---------------------------------------------===//
+//
+// 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 "ConjTest.h"
+
+#include "src/complex/conjf16.h"
+
+LIST_CONJ_TESTS(cfloat16, float16, LIBC_NAMESPACE::conjf16)
diff --git a/libc/test/src/complex/conjf_test.cpp b/libc/test/src/complex/conjf_test.cpp
new file mode 100644
index 000000000000..34b00b37996c
--- /dev/null
+++ b/libc/test/src/complex/conjf_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for conjf -----------------------------------------------===//
+//
+// 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 "ConjTest.h"
+
+#include "src/complex/conjf.h"
+
+LIST_CONJ_TESTS(_Complex float, float, LIBC_NAMESPACE::conjf)
diff --git a/libc/test/src/complex/conjl_test.cpp b/libc/test/src/complex/conjl_test.cpp
new file mode 100644
index 000000000000..ec299f963154
--- /dev/null
+++ b/libc/test/src/complex/conjl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for conjl -----------------------------------------------===//
+//
+// 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 "ConjTest.h"
+
+#include "src/complex/conjl.h"
+
+LIST_CONJ_TESTS(_Complex long double, long double, LIBC_NAMESPACE::conjl)
diff --git a/libc/test/src/complex/cproj_test.cpp b/libc/test/src/complex/cproj_test.cpp
new file mode 100644
index 000000000000..83e5760f9ca8
--- /dev/null
+++ b/libc/test/src/complex/cproj_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for cproj -----------------------------------------------===//
+//
+// 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 "CprojTest.h"
+
+#include "src/complex/cproj.h"
+
+LIST_CPROJ_TESTS(_Complex double, double, LIBC_NAMESPACE::cproj)
diff --git a/libc/test/src/complex/cprojf128_test.cpp b/libc/test/src/complex/cprojf128_test.cpp
new file mode 100644
index 000000000000..7b41eb5cf5f9
--- /dev/null
+++ b/libc/test/src/complex/cprojf128_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for cprojf128 -------------------------------------------===//
+//
+// 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 "CprojTest.h"
+
+#include "src/complex/cprojf128.h"
+
+LIST_CPROJ_TESTS(cfloat128, float128, LIBC_NAMESPACE::cprojf128)
diff --git a/libc/test/src/complex/cprojf16_test.cpp b/libc/test/src/complex/cprojf16_test.cpp
new file mode 100644
index 000000000000..db9b7b9316bc
--- /dev/null
+++ b/libc/test/src/complex/cprojf16_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for cprojf16 --------------------------------------------===//
+//
+// 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 "CprojTest.h"
+
+#include "src/complex/cprojf16.h"
+
+LIST_CPROJ_TESTS(cfloat16, float16, LIBC_NAMESPACE::cprojf16)
diff --git a/libc/test/src/complex/cprojf_test.cpp b/libc/test/src/complex/cprojf_test.cpp
new file mode 100644
index 000000000000..7123ed4e28d4
--- /dev/null
+++ b/libc/test/src/complex/cprojf_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for cprojf ----------------------------------------------===//
+//
+// 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 "CprojTest.h"
+
+#include "src/complex/cprojf.h"
+
+LIST_CPROJ_TESTS(_Complex float, float, LIBC_NAMESPACE::cprojf)
diff --git a/libc/test/src/complex/cprojl_test.cpp b/libc/test/src/complex/cprojl_test.cpp
new file mode 100644
index 000000000000..0858bf460188
--- /dev/null
+++ b/libc/test/src/complex/cprojl_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for cprojl ----------------------------------------------===//
+//
+// 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 "CprojTest.h"
+
+#include "src/complex/cprojl.h"
+
+LIST_CPROJ_TESTS(_Complex long double, long double, LIBC_NAMESPACE::cprojl)
diff --git a/libc/test/src/complex/crealf128_test.cpp b/libc/test/src/complex/crealf128_test.cpp
index 7626eeebca27..0d1c26df7737 100644
--- a/libc/test/src/complex/crealf128_test.cpp
+++ b/libc/test/src/complex/crealf128_test.cpp
@@ -10,8 +10,4 @@
#include "src/complex/crealf128.h"
-#if defined(LIBC_TYPES_HAS_CFLOAT128)
-
LIST_CREAL_TESTS(cfloat128, float128, LIBC_NAMESPACE::crealf128)
-
-#endif // LIBC_TYPES_HAS_CFLOAT128
diff --git a/libc/test/src/complex/crealf16_test.cpp b/libc/test/src/complex/crealf16_test.cpp
index 97346aad615f..b8560d74d35b 100644
--- a/libc/test/src/complex/crealf16_test.cpp
+++ b/libc/test/src/complex/crealf16_test.cpp
@@ -10,8 +10,4 @@
#include "src/complex/crealf16.h"
-#if defined(LIBC_TYPES_HAS_CFLOAT16)
-
LIST_CREAL_TESTS(cfloat16, float16, LIBC_NAMESPACE::crealf16)
-
-#endif // LIBC_TYPES_HAS_CFLOAT16