1 /*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <gtest/gtest.h>
18
19 // libc++ actively gets in the way of including <complex.h> from C++, so we
20 // have to declare the complex math functions ourselves.
21 // (libc++ also seems to have really bad implementations of its own that ignore
22 // the intricacies of floating point math.)
23 // http://llvm.org/bugs/show_bug.cgi?id=21504
24
25 #include <math.h> // For M_PI.
26
27 extern "C" double cabs(double _Complex);
TEST(complex,cabs)28 TEST(complex, cabs) {
29 ASSERT_EQ(0.0, cabs(0));
30 }
31
32 extern "C" float cabsf(float _Complex);
TEST(complex,cabsf)33 TEST(complex, cabsf) {
34 ASSERT_EQ(0.0, cabsf(0));
35 }
36
37 extern "C" long double cabsl(long double _Complex);
TEST(complex,cabsl)38 TEST(complex, cabsl) {
39 ASSERT_EQ(0.0, cabsl(0));
40 }
41
42 extern "C" double _Complex cacos(double _Complex);
TEST(complex,cacos)43 TEST(complex, cacos) {
44 ASSERT_EQ(M_PI/2.0, cacos(0.0));
45 }
46
47 extern "C" float _Complex cacosf(float _Complex);
TEST(complex,cacosf)48 TEST(complex, cacosf) {
49 ASSERT_EQ(static_cast<float>(M_PI)/2.0f, cacosf(0.0));
50 }
51
52 extern "C" double _Complex cacosh(double _Complex);
TEST(complex,cacosh)53 TEST(complex, cacosh) {
54 ASSERT_EQ(0.0, cacosh(1.0));
55 }
56
57 extern "C" float _Complex cacoshf(float _Complex);
TEST(complex,cacoshf)58 TEST(complex, cacoshf) {
59 ASSERT_EQ(0.0, cacoshf(1.0));
60 }
61
62 extern "C" double carg(double _Complex);
TEST(complex,carg)63 TEST(complex, carg) {
64 ASSERT_EQ(0.0, carg(0));
65 }
66
67 extern "C" float cargf(float _Complex);
TEST(complex,cargf)68 TEST(complex, cargf) {
69 ASSERT_EQ(0.0, cargf(0));
70 }
71
72 extern "C" long double cargl(long double _Complex);
TEST(complex,cargl)73 TEST(complex, cargl) {
74 ASSERT_EQ(0.0, cargl(0));
75 }
76
77 extern "C" double _Complex casin(double _Complex);
TEST(complex,casin)78 TEST(complex, casin) {
79 ASSERT_EQ(0.0, casin(0));
80 }
81
82 extern "C" float _Complex casinf(float _Complex);
TEST(complex,casinf)83 TEST(complex, casinf) {
84 ASSERT_EQ(0.0, casinf(0));
85 }
86
87 extern "C" double _Complex casinh(double _Complex);
TEST(complex,casinh)88 TEST(complex, casinh) {
89 ASSERT_EQ(0.0, casinh(0));
90 }
91
92 extern "C" float _Complex casinhf(float _Complex);
TEST(complex,casinhf)93 TEST(complex, casinhf) {
94 ASSERT_EQ(0.0, casinhf(0));
95 }
96
97 extern "C" double _Complex catan(double _Complex);
TEST(complex,catan)98 TEST(complex, catan) {
99 ASSERT_EQ(0.0, catan(0));
100 }
101
102 extern "C" float _Complex catanf(float _Complex);
TEST(complex,catanf)103 TEST(complex, catanf) {
104 ASSERT_EQ(0.0, catanf(0));
105 }
106
107 extern "C" double _Complex catanh(double _Complex);
TEST(complex,catanh)108 TEST(complex, catanh) {
109 ASSERT_EQ(0.0, catanh(0));
110 }
111
112 extern "C" float _Complex catanhf(float _Complex);
TEST(complex,catanhf)113 TEST(complex, catanhf) {
114 ASSERT_EQ(0.0, catanhf(0));
115 }
116
117 extern "C" double _Complex ccos(double _Complex);
TEST(complex,ccos)118 TEST(complex, ccos) {
119 ASSERT_EQ(1.0, ccos(0));
120 }
121
122 extern "C" float _Complex ccosf(float _Complex);
TEST(complex,ccosf)123 TEST(complex, ccosf) {
124 ASSERT_EQ(1.0, ccosf(0));
125 }
126
127 extern "C" double _Complex ccosh(double _Complex);
TEST(complex,ccosh)128 TEST(complex, ccosh) {
129 ASSERT_EQ(1.0, ccosh(0));
130 }
131
132 extern "C" float _Complex ccoshf(float _Complex);
TEST(complex,ccoshf)133 TEST(complex, ccoshf) {
134 ASSERT_EQ(1.0, ccoshf(0));
135 }
136
137 extern "C" double _Complex cexp(double _Complex);
TEST(complex,cexp)138 TEST(complex, cexp) {
139 ASSERT_EQ(1.0, cexp(0));
140 }
141
142 extern "C" float _Complex cexpf(float _Complex);
TEST(complex,cexpf)143 TEST(complex, cexpf) {
144 ASSERT_EQ(1.0, cexpf(0));
145 }
146
147 extern "C" double cimag(double _Complex);
TEST(complex,cimag)148 TEST(complex, cimag) {
149 ASSERT_EQ(0.0, cimag(0));
150 }
151
152 extern "C" float cimagf(float _Complex);
TEST(complex,cimagf)153 TEST(complex, cimagf) {
154 ASSERT_EQ(0.0f, cimagf(0));
155 }
156
157 extern "C" long double cimagl(long double _Complex);
TEST(complex,cimagl)158 TEST(complex, cimagl) {
159 ASSERT_EQ(0.0, cimagl(0));
160 }
161
162 extern "C" double _Complex conj(double _Complex);
TEST(complex,conj)163 TEST(complex, conj) {
164 ASSERT_EQ(0.0, conj(0));
165 }
166
167 extern "C" float _Complex conjf(float _Complex);
TEST(complex,conjf)168 TEST(complex, conjf) {
169 ASSERT_EQ(0.0f, conjf(0));
170 }
171
172 extern "C" long double _Complex conjl(long double _Complex);
TEST(complex,conjl)173 TEST(complex, conjl) {
174 ASSERT_EQ(0.0, conjl(0));
175 }
176
177 extern "C" double _Complex cproj(double _Complex);
TEST(complex,cproj)178 TEST(complex, cproj) {
179 ASSERT_EQ(0.0, cproj(0));
180 }
181
182 extern "C" float _Complex cprojf(float _Complex);
TEST(complex,cprojf)183 TEST(complex, cprojf) {
184 ASSERT_EQ(0.0f, cprojf(0));
185 }
186
187 extern "C" long double _Complex cprojl(long double _Complex);
TEST(complex,cprojl)188 TEST(complex, cprojl) {
189 ASSERT_EQ(0.0, cprojl(0));
190 }
191
192 extern "C" double creal(double _Complex);
TEST(complex,creal)193 TEST(complex, creal) {
194 ASSERT_EQ(0.0, creal(0));
195 }
196
197 extern "C" float crealf(float _Complex);
TEST(complex,crealf)198 TEST(complex, crealf) {
199 ASSERT_EQ(0.0f, crealf(0));
200 }
201
202 extern "C" long double creall(long double _Complex);
TEST(complex,creall)203 TEST(complex, creall) {
204 ASSERT_EQ(0.0, creall(0));
205 }
206
207 extern "C" double _Complex csin(double _Complex);
TEST(complex,csin)208 TEST(complex, csin) {
209 ASSERT_EQ(0.0, csin(0));
210 }
211
212 extern "C" float _Complex csinf(float _Complex);
TEST(complex,csinf)213 TEST(complex, csinf) {
214 ASSERT_EQ(0.0, csinf(0));
215 }
216
217 extern "C" double _Complex csinh(double _Complex);
TEST(complex,csinh)218 TEST(complex, csinh) {
219 ASSERT_EQ(0.0, csinh(0));
220 }
221
222 extern "C" float _Complex csinhf(float _Complex);
TEST(complex,csinhf)223 TEST(complex, csinhf) {
224 ASSERT_EQ(0.0, csinhf(0));
225 }
226
227 extern "C" double _Complex csqrt(double _Complex);
TEST(complex,csqrt)228 TEST(complex, csqrt) {
229 ASSERT_EQ(0.0, csqrt(0));
230 }
231
232 extern "C" float _Complex csqrtf(float _Complex);
TEST(complex,csqrtf)233 TEST(complex, csqrtf) {
234 ASSERT_EQ(0.0f, csqrt(0));
235 }
236
237 extern "C" long double _Complex csqrtl(long double _Complex);
TEST(complex,csqrtl)238 TEST(complex, csqrtl) {
239 ASSERT_EQ(0.0, csqrtl(0));
240 }
241
242 extern "C" double _Complex ctan(double _Complex);
TEST(complex,ctan)243 TEST(complex, ctan) {
244 ASSERT_EQ(0.0, ctan(0));
245 }
246
247 extern "C" float _Complex ctanf(float _Complex);
TEST(complex,ctanf)248 TEST(complex, ctanf) {
249 ASSERT_EQ(0.0, ctanf(0));
250 }
251
252 extern "C" double _Complex ctanh(double _Complex);
TEST(complex,ctanh)253 TEST(complex, ctanh) {
254 ASSERT_EQ(0.0, ctanh(0));
255 }
256
257 extern "C" float _Complex ctanhf(float _Complex);
TEST(complex,ctanhf)258 TEST(complex, ctanhf) {
259 ASSERT_EQ(0.0, ctanhf(0));
260 }
261