summaryrefslogtreecommitdiff
path: root/sal/qa/rtl/math/test-rtl-math.cxx
diff options
context:
space:
mode:
authorSakura286 <sakura286@outlook.com>2024-10-15 17:49:21 +0800
committerEike Rathke <erack@redhat.com>2024-10-17 11:46:34 +0200
commit50656d54131abeefc88a6ceb77e7f60686ce2fea (patch)
treed410075165379b246849335f840bab9f447231a4 /sal/qa/rtl/math/test-rtl-math.cxx
parent92f952971908e84ea1c32ab93c8d6b2b6d66b392 (diff)
extract NaN payload test from single unit test
Change-Id: I51a029c9ac729352fe435b9a70c5e8bd2cf746b1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174964 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'sal/qa/rtl/math/test-rtl-math.cxx')
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx23
1 files changed, 3 insertions, 20 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index 7e28356f625a..8f669f265ecf 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -24,6 +24,7 @@
#include <rtl/math.hxx>
#include <rtl/ustring.hxx>
#include <limits>
+#include <test/nanpayload_test.hxx>
template<> inline std::string CPPUNIT_NS::assertion_traits<rtl_math_ConversionStatus>::toString(
const rtl_math_ConversionStatus& x )
@@ -667,26 +668,8 @@ public:
}
void test_payloadNaN() {
- // Test that a quiet NaN payload is propagated and behaves as we
- // expect. Ideally that could be done with a constexpr in
- // sal/rtl/math.cxx to fail already during compile time instead of make
- // check, but..
- // See
- // https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/nan-propagation.pdf
- double fVal1 = std::numeric_limits<double>::quiet_NaN();
- reinterpret_cast<sal_math_Double*>(&fVal1)->nan_parts.fraction_lo = 0xbeef;
- const double fVal2 = 0 + fVal1;
- CPPUNIT_ASSERT(std::isnan(fVal2));
- CPPUNIT_ASSERT_EQUAL_MESSAGE("Your platform does not support propagation of NaN payloads.",
- static_cast<sal_uInt32>(0xbeef),
- static_cast<sal_uInt32>(reinterpret_cast<const sal_math_Double*>(&fVal2)->nan_parts.fraction_lo));
- reinterpret_cast<sal_math_Double*>(&fVal1)->nan_parts.fraction_lo = 0xdead;
- const double fVal3 = fVal1 + fVal2;
- // Result is one of the payloaded NaNs but the standard does not
- // specify which.
- CPPUNIT_ASSERT_MESSAGE("Your platform does not support propagation of two combined NaN payloads.",
- 0xbeef == reinterpret_cast<const sal_math_Double*>(&fVal3)->nan_parts.fraction_lo ||
- 0xdead == reinterpret_cast<const sal_math_Double*>(&fVal3)->nan_parts.fraction_lo);
+ NanPayloadTest nanTest;
+ CPPUNIT_ASSERT_MESSAGE(nanTest.getMessage(), nanTest.getIfSupported());
}
CPPUNIT_TEST_SUITE(Test);