File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -484,6 +484,21 @@ add_libc_test(
484484 libc.include .llvm-libc-macros .math_function_macros
485485)
486486
487+ add_libc_test(
488+ math_constants_c_test
489+ C_TEST
490+ UNIT_TEST_ONLY
491+ SUITE
492+ libc_include_tests
493+ SRCS
494+ math_constants_test.c
495+ COMPILE_OPTIONS
496+ -Wall
497+ -Werror
498+ DEPENDS
499+ libc.include .llvm-libc-macros .math_macros
500+ )
501+
487502# Test `#include <...>` of each header in each available language mode.
488503# This is gated on -DLLVM_LIBC_BUILD_HEADER_TESTS=ON until all the bugs
489504# in headers are fixed so the tests all compile.
Original file line number Diff line number Diff line change 1+ //===-- Unittests for math constants --------------------------------------===//
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+ #include "include/llvm-libc-macros/math-macros.h"
9+
10+ #define IS_DOUBLE (X ) _Generic((X), double: 1, default: 0)
11+
12+ #define IS_FLOAT (X ) _Generic((X), float: 1, default: 0)
13+
14+ // check if macro is defined
15+ #ifndef M_PI
16+ #error "M_PI macro is not defined"
17+ #else
18+ int main (void ) {
19+ _Static_assert (IS_DOUBLE (M_PI ), "M_PI is not of double type." );
20+ _Static_assert (IS_FLOAT (M_PIf ), "M_PIf is not of float type." );
21+ return 0 ;
22+ }
23+ #endif
You can’t perform that action at this time.
0 commit comments