[libc-commits] [libc] [libc] Add a C unit test framework wrapper and convert existing tests (PR #213657)

via libc-commits libc-commits at lists.llvm.org
Mon Aug 3 05:39:48 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c,h -- libc/test/UnitTest/LibcCTest.cpp libc/test/UnitTest/LibcCTest.h libc/test/include/fpclassify_test.c libc/test/include/isfinite_test.c libc/test/include/isinf_test.c libc/test/include/isnan_test.c libc/test/include/isnormal_test.c libc/test/include/issubnormal_test.c libc/test/include/iszero_test.c libc/test/include/math_constants_test.c libc/test/include/signbit_test.c libc/test/include/stdbit_test.c --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libc/test/UnitTest/LibcCTest.cpp b/libc/test/UnitTest/LibcCTest.cpp
index 4436fa937..8e19f7dd3 100644
--- a/libc/test/UnitTest/LibcCTest.cpp
+++ b/libc/test/UnitTest/LibcCTest.cpp
@@ -28,7 +28,7 @@ static CTest c_test_instance;
 extern "C" void libc_c_test_anchor() {}
 
 extern "C" void libc_c_test_fail(const char *cond, int expected,
-                                   const char *file, int line) {
+                                 const char *file, int line) {
   LIBC_NAMESPACE::testing::internal::test(
       LIBC_NAMESPACE::testing::TestCond::EQ, !expected,
       static_cast<bool>(expected), cond, expected ? "true" : "false",
diff --git a/libc/test/UnitTest/LibcCTest.h b/libc/test/UnitTest/LibcCTest.h
index c0cd1b91e..cac8a271e 100644
--- a/libc/test/UnitTest/LibcCTest.h
+++ b/libc/test/UnitTest/LibcCTest.h
@@ -46,8 +46,8 @@ __END_C_DECLS
     }                                                                          \
   } while (0)
 
-#define EXPECT_TRUE(cond)  LIBC_C_TEST_SCAFFOLDING_(cond, 1, )
-#define ASSERT_TRUE(cond)  LIBC_C_TEST_SCAFFOLDING_(cond, 1, return)
+#define EXPECT_TRUE(cond) LIBC_C_TEST_SCAFFOLDING_(cond, 1, )
+#define ASSERT_TRUE(cond) LIBC_C_TEST_SCAFFOLDING_(cond, 1, return)
 
 #define EXPECT_FALSE(cond) LIBC_C_TEST_SCAFFOLDING_(cond, 0, )
 #define ASSERT_FALSE(cond) LIBC_C_TEST_SCAFFOLDING_(cond, 0, return)
diff --git a/libc/test/include/fpclassify_test.c b/libc/test/include/fpclassify_test.c
index 4717e1e58..0d265552b 100644
--- a/libc/test/include/fpclassify_test.c
+++ b/libc/test/include/fpclassify_test.c
@@ -17,7 +17,7 @@ TEST(fpclassify) {
   EXPECT_TRUE(fpclassify(-1.726) == FP_NORMAL);
   EXPECT_TRUE(fpclassify(1.426L) == FP_NORMAL);
   EXPECT_TRUE(fpclassify(-0.0f) == FP_ZERO);
-  EXPECT_TRUE(fpclassify(0.0) == FP_ZERO); 
+  EXPECT_TRUE(fpclassify(0.0) == FP_ZERO);
   EXPECT_TRUE(fpclassify(-0.0L) == FP_ZERO);
 }
 #endif

``````````

</details>


https://github.com/llvm/llvm-project/pull/213657


More information about the libc-commits mailing list