filter/qa/unit/svg.cxx | 5 ++--- sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-)
New commits: commit d3e1d30ac7099584552ebf9c96dd21fdf7b1d9c9 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Fri Sep 17 07:47:09 2021 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Sep 17 08:53:52 2021 +0200 Some test-code simplifications, using starts/endsWith rest parameter Change-Id: I3376ddc30e8ddc0e2dfc052ab47fe086108e015a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122221 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 4c37dac61548..e1b54fb2a294 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -117,11 +117,10 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testSemiTransparentLine) xmlDocUniquePtr pXmlDoc = parseXmlStream(&aStream); OUString aStyle = getXPath( pXmlDoc, "//svg:g[@class='com.sun.star.drawing.LineShape']/svg:g/svg:g", "style"); - OUString aPrefix("opacity: "); // Without the accompanying fix in place, this test would have failed, as the style was // "mask:url(#mask1)", not "opacity: <value>". - CPPUNIT_ASSERT(aStyle.startsWith(aPrefix)); - int nPercent = std::round(aStyle.copy(aPrefix.getLength()).toDouble() * 100); + CPPUNIT_ASSERT(aStyle.startsWith("opacity: ", &aStyle)); + int nPercent = std::round(aStyle.toDouble() * 100); // Make sure that the line is still 30% opaque, rather than completely invisible. CPPUNIT_ASSERT_EQUAL(30, nPercent); } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index deb8c5a8bb05..c0ed9c95a9e7 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -353,20 +353,20 @@ CPPUNIT_TEST_FIXTURE(Test, testFDO74215) const OUString sStyle = getXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style"); { - const OUString sWidth = sStyle.getToken(0, ';'); - CPPUNIT_ASSERT(sWidth.startsWith("width:")); - CPPUNIT_ASSERT(sWidth.endsWith("pt")); - const double fWidth = sWidth.copy(6, sWidth.getLength() - 8).toDouble(); + OUString sWidth = sStyle.getToken(0, ';'); + CPPUNIT_ASSERT(sWidth.startsWith("width:", &sWidth)); + CPPUNIT_ASSERT(sWidth.endsWith("pt", &sWidth)); + const double fWidth = sWidth.toDouble(); const double fXScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIX(); // note: used to fail on Mac with 14.7945205479452 vs. 14.8 // note: used to fail on another Mac with 12.1348314606742 vs 12.15 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fXScaleFactor, fWidth, 0.1); } { - const OUString sHeight = sStyle.getToken(1, ';'); - CPPUNIT_ASSERT(sHeight.startsWith("height:")); - CPPUNIT_ASSERT(sHeight.endsWith("pt")); - const double fHeight = sHeight.copy(7, sHeight.getLength() - 9).toDouble(); + OUString sHeight = sStyle.getToken(1, ';'); + CPPUNIT_ASSERT(sHeight.startsWith("height:", &sHeight)); + CPPUNIT_ASSERT(sHeight.endsWith("pt", &sHeight)); + const double fHeight = sHeight.toDouble(); const double fYScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIY(); CPPUNIT_ASSERT_DOUBLES_EQUAL(11.25 * fYScaleFactor, fHeight, 0.1); }