From 34abbb53f347f53892cc9dde60e36499588681fd Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Sat, 24 Oct 2015 22:05:36 +0200 Subject: unit tests for rtl_math_expm1() and rtl_math_log1p() Change-Id: I1b573365d55f6455e892b4b5b98a7090de5caf4c --- sal/qa/rtl/math/test-rtl-math.cxx | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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(); }; -- cgit