diff options
author | Eike Rathke <erack@redhat.com> | 2015-10-24 22:05:36 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-10-24 22:07:40 +0200 |
commit | 34abbb53f347f53892cc9dde60e36499588681fd (patch) | |
tree | ee1083455592f315247bd758e19dd373b68f9160 /sal | |
parent | 04967cba8e71e178915068e237a96e32a8cb3e9e (diff) |
unit tests for rtl_math_expm1() and rtl_math_log1p()
Change-Id: I1b573365d55f6455e892b4b5b98a7090de5caf4c
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index b462de480431..1d3f07fee9c0 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -120,12 +120,60 @@ public: CPPUNIT_ASSERT_EQUAL(true,rtl::math::isNan(x)); } + void test_expm1() { + double x, res; + x = 0.0; + res = rtl::math::expm1(x); + CPPUNIT_ASSERT_EQUAL(0.0,res); + x = -0.0; + res = rtl::math::expm1(x); + CPPUNIT_ASSERT_EQUAL(-0.0,res); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isSignBitSet(res)); + rtl::math::setInf( &x, false); + res = rtl::math::expm1(x); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isInf(res) && !rtl::math::isSignBitSet(res)); + rtl::math::setInf( &x, true); + res = rtl::math::expm1(x); + CPPUNIT_ASSERT_EQUAL(-1.0,res); + rtl::math::setNan( &x); + res = rtl::math::expm1(x); + CPPUNIT_ASSERT_EQUAL(true,rtl::math::isNan(x)); + } + + void test_log1p() { + double x, res; + x = 0.0; + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(0.0,res); + x = -0.0; + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(-0.0,res); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isSignBitSet(res)); + rtl::math::setInf( &x, false); + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isInf(res) && !rtl::math::isSignBitSet(res)); + x = -1.0; + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isInf(res) && rtl::math::isSignBitSet(res)); + x = -1.1; + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isNan(res)); + rtl::math::setInf( &x, true); + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(true, rtl::math::isNan(res)); + rtl::math::setNan( &x); + res = rtl::math::log1p(x); + CPPUNIT_ASSERT_EQUAL(true,rtl::math::isNan(x)); + } + CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST(test_stringToDouble_good); CPPUNIT_TEST(test_stringToDouble_bad); CPPUNIT_TEST(test_stringToDouble_exponent_without_digit); CPPUNIT_TEST(test_erf); CPPUNIT_TEST(test_erfc); + CPPUNIT_TEST(test_expm1); + CPPUNIT_TEST(test_log1p); CPPUNIT_TEST_SUITE_END(); }; |