[Libreoffice-commits] core.git: sal/qa

Takeshi Abe tabe at fixedpoint.jp
Tue Jan 23 13:39:49 UTC 2018


 sal/qa/rtl/math/test-rtl-math.cxx |   71 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

New commits:
commit f16fdfa559ab62ccde2c2c0cbe1fc9e5ca2f3630
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Dec 10 01:17:49 2017 +0900

    Add unit tests for rtl::math's inverse hyperbolic functions
    
    based on i#97605's test cases.
    
    Change-Id: Id7e57914553ba8801a624f667979badc191108e5
    Reviewed-on: https://gerrit.libreoffice.org/46152
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 116cc6009fcc..3e718940b097 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -25,6 +25,7 @@
 #include <rtl/math.hxx>
 #include <rtl/ustring.h>
 #include <rtl/ustring.hxx>
+#include <limits>
 
 CPPUNIT_NS_BEGIN
 
@@ -344,6 +345,73 @@ public:
         CPPUNIT_ASSERT_EQUAL(true,rtl::math::isNan(res));
     }
 
+    void test_acosh() {
+        double res;
+
+        res = rtl::math::acosh(-1.0); // NaN
+        CPPUNIT_ASSERT(rtl::math::isNan(res));
+
+        res = rtl::math::acosh(0.0); // NaN
+        CPPUNIT_ASSERT(rtl::math::isNan(res));
+
+        res = rtl::math::acosh(0.5); // NaN
+        CPPUNIT_ASSERT(rtl::math::isNan(res));
+
+        CPPUNIT_ASSERT_EQUAL(0.0, rtl::math::acosh(1.0));
+
+        res = rtl::math::acosh(std::numeric_limits<double>::infinity()); // +Inf
+        CPPUNIT_ASSERT(!rtl::math::isSignBitSet(res));
+        CPPUNIT_ASSERT(rtl::math::isInf(res));
+
+        // #i97605
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(692.56728736744176, rtl::math::acosh(3e+300), 1e-15);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.014142017775252324, rtl::math::acosh(1.0001), 1e-15);
+    }
+
+    void test_asinh() {
+        double res;
+
+        res = rtl::math::asinh(-std::numeric_limits<double>::infinity()); // -Inf
+        CPPUNIT_ASSERT(rtl::math::isSignBitSet(res));
+        CPPUNIT_ASSERT(rtl::math::isInf(res));
+
+        CPPUNIT_ASSERT_EQUAL(0.0, rtl::math::asinh(0.0));
+
+        res = rtl::math::asinh(std::numeric_limits<double>::infinity()); // +Inf
+        CPPUNIT_ASSERT(!rtl::math::isSignBitSet(res));
+        CPPUNIT_ASSERT(rtl::math::isInf(res));
+
+        // #i97605
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(691.67568924815798, rtl::math::asinh(1.23e+300), 1e-15);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0350378961923076, rtl::math::asinh(1.23), 1e-16);
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23e-300, rtl::math::asinh(1.23e-300), 1e-303);
+
+        // asinh is an odd function
+        CPPUNIT_ASSERT_EQUAL(-rtl::math::asinh(1.23e+300), rtl::math::asinh(-1.23e+300));
+        CPPUNIT_ASSERT_EQUAL(-rtl::math::asinh(1.23), rtl::math::asinh(-1.23));
+        CPPUNIT_ASSERT_EQUAL(-rtl::math::asinh(1.23e-300), rtl::math::asinh(-1.23e-300));
+    }
+
+    void test_atanh() {
+        double res;
+
+        res = rtl::math::atanh(-2.0); // NaN
+        CPPUNIT_ASSERT(rtl::math::isNan(res));
+
+        res = rtl::math::atanh(-1.0); // -Inf
+        CPPUNIT_ASSERT(rtl::math::isSignBitSet(res));
+        CPPUNIT_ASSERT(rtl::math::isInf(res));
+
+        CPPUNIT_ASSERT_EQUAL(0.0, rtl::math::atanh(0.0));
+
+        res = rtl::math::atanh(1.0); // +Inf
+        CPPUNIT_ASSERT(!rtl::math::isSignBitSet(res));
+        CPPUNIT_ASSERT(rtl::math::isInf(res));
+
+        res = rtl::math::atanh(2.0); // NaN
+        CPPUNIT_ASSERT(rtl::math::isNan(res));
+    }
+
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(test_stringToDouble_good);
     CPPUNIT_TEST(test_stringToDouble_bad);
@@ -354,6 +422,9 @@ public:
     CPPUNIT_TEST(test_expm1);
     CPPUNIT_TEST(test_log1p);
     CPPUNIT_TEST(test_approx);
+    CPPUNIT_TEST(test_acosh);
+    CPPUNIT_TEST(test_asinh);
+    CPPUNIT_TEST(test_atanh);
     CPPUNIT_TEST_SUITE_END();
 };
 


More information about the Libreoffice-commits mailing list