summaryrefslogtreecommitdiff
path: root/tests/complex_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-07-23 17:04:58 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-07-23 17:04:58 -0700
commit8a6afe38a7ccbc93e10eec8d14bf8ffa8876bb32 (patch)
tree068475a0a85f6ed4919d4443fb39e7027e8485ed /tests/complex_test.cpp
parent0ce80bd10a8b5450d1e2f861974334602b246026 (diff)
parent70c102e536d8320740fb8cbea9d96d08bd45f9ed (diff)
Merge "libm: add tests that would have caught the recent regression." am: 94ab04c17a
am: 70c102e536 Change-Id: Ic2ab5f0f591bd5c65bad32a9c342c2ff674f7cc2
Diffstat (limited to 'tests/complex_test.cpp')
-rw-r--r--tests/complex_test.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/tests/complex_test.cpp b/tests/complex_test.cpp
index 2aaa19231..3bbddbb6c 100644
--- a/tests/complex_test.cpp
+++ b/tests/complex_test.cpp
@@ -317,12 +317,64 @@ TEST(COMPLEX_TEST, ctanl) {
TEST(COMPLEX_TEST, ctanh) {
ASSERT_EQ(0.0, ctanh(0));
+
+ double complex z;
+
+ // If z is NaN+0i, the result is NaN+0i.
+ z = ctanh(nan("") + 0i);
+ ASSERT_TRUE(isnan(creal(z)));
+ ASSERT_EQ(0.0, cimag(z));
+
+ // If z is NaN+yi, the result is NaN+NaNi.
+ z = ctanh(nan("") + 2.0i);
+ ASSERT_TRUE(isnan(creal(z)));
+ ASSERT_TRUE(isnan(cimag(z)));
+
+ // If z is NaN+NaNi, the result is NaN+NaNi.
+ z = ctanh(nan("") + nan("") * I);
+ ASSERT_TRUE(isnan(creal(z)));
+ ASSERT_TRUE(isnan(cimag(z)));
}
TEST(COMPLEX_TEST, ctanhf) {
- ASSERT_EQ(0.0, ctanhf(0));
+ ASSERT_EQ(0.0f, ctanhf(0.0f));
+
+ float complex z;
+
+ // If z is NaN+0i, the result is NaN+0i.
+ z = ctanhf(nanf("") + 0.0fi);
+ ASSERT_TRUE(isnan(crealf(z)));
+ ASSERT_EQ(0.0f, cimagf(z));
+
+ // If z is NaN+yi, the result is NaN+NaNi.
+ z = ctanhf(nanf("") + 2.0fi);
+ ASSERT_TRUE(isnan(crealf(z)));
+ ASSERT_TRUE(isnan(cimagf(z)));
+
+ // If z is NaN+NaNi, the result is NaN+NaNi.
+ z = ctanhf(nanf("") + nanf("") * I);
+ ASSERT_TRUE(isnan(crealf(z)));
+ ASSERT_TRUE(isnan(cimagf(z)));
}
TEST(COMPLEX_TEST, ctanhl) {
- ASSERT_EQ(0.0, ctanhl(0));
+ ASSERT_EQ(0.0L, ctanhl(0.0L));
+
+ long double complex z;
+
+ // If z is NaN+0i, the result is NaN+0i.
+ z = ctanhl(nanl("") + 0.0Li);
+ ASSERT_TRUE(isnan(creall(z)));
+ // TODO: this case is currently broken in the netbsd ctanhl.
+ // ASSERT_EQ(0.0L, cimagl(z));
+
+ // If z is NaN+yi, the result is NaN+NaNi.
+ z = ctanhl(nanl("") + 2.0Li);
+ ASSERT_TRUE(isnan(creall(z)));
+ ASSERT_TRUE(isnan(cimagl(z)));
+
+ // If z is NaN+NaNi, the result is NaN+NaNi.
+ z = ctanhl(nanl("") + nanl("") * I);
+ ASSERT_TRUE(isnan(creall(z)));
+ ASSERT_TRUE(isnan(cimagl(z)));
}