Skip to content

Commit b8ba7f5

Browse files
author
github-actions
committed
Add complex math tests
1 parent 80bcef0 commit b8ba7f5

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

.github/scripts/tests/build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ source `dirname ${BASH_SOURCE[0]}`/../config.sh
44

55
echo "::group::Build Aarch64 tests"
66
cd tests
7-
cmake -S . -B build
7+
if [ $RUN_CONFIG = 1 ] || [ ! -f build/CMakeCache.txt ] ; then
8+
cmake -S . -B build
9+
fi
810
cmake --build build
911
echo "::endgroup::"

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ if (NOT DEFINED ENV{TARGET})
44
set(ENV{TARGET} "aarch64-w64-mingw32")
55
endif()
66
if (NOT DEFINED ENV{TOOLCHAIN_PATH})
7-
set(ENV{TOOLCHAIN_PATH} "$ENV{HOME}/cross")
7+
set(ENV{TOOLCHAIN_PATH} "$ENV{HOME}/cross-aarch64-w64-mingw32-msvcrt")
88
endif()
99

1010
set(CMAKE_C_COMPILER "$ENV{TOOLCHAIN_PATH}/bin/$ENV{TARGET}-gcc")

tests/math-test.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <stdio.h>
2+
#include <complex.h>
23

34
_Float128 foo(_Float128 x)
45
{
@@ -33,4 +34,21 @@ void math_test()
3334
baz(1.2Q);
3435

3536
printf("ok\n");
37+
}
38+
39+
void cexp_test()
40+
{
41+
_Complex double z = 1.0 + 2.0 * I;
42+
_Complex double w = __builtin_cexp(z);
43+
44+
printf("%f + %f * I\n", creal(w), cimag(w));
45+
}
46+
47+
48+
void ccos_test()
49+
{
50+
_Complex double z = 1.0 + 2.0 * I;
51+
_Complex double w = __builtin_ccos(z);
52+
53+
printf("%f + %f * I\n", creal(w), cimag(w));
3654
}

tests/math-test.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
#include <gtest/gtest.h>
22

33
extern "C" void math_test();
4+
extern "C" void cexp_test();
5+
extern "C" void ccos_test();
46

57
TEST(Aarch64MinGW, MathTest)
68
{
79
math_test();
810
}
11+
12+
TEST(Aarch64MinGW, CexpTest)
13+
{
14+
cexp_test();
15+
}
16+
17+
TEST(Aarch64MinGW, CcosTest)
18+
{
19+
ccos_test();
20+
}

0 commit comments

Comments
 (0)