diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2021-02-08 07:48:59 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2021-02-08 09:15:01 +0100 |
commit | 6b00d0576a310796590631d14c54d7d5ea6814ac (patch) | |
tree | 2e11a4454592be39cfeaa68458cae964d8cdef5e /chart2 | |
parent | 17149f65f03a34e88bb4a10abcd20e6891f5d7ca (diff) |
Improve loplugin:cppunitassertequal for CPPUNIT_ASSERT(a && b)
...by re-enabling the code temporarily #if'ed-out in
a528392e71bc70136021be4e3d83732fccbb885e "Fixed/improved
loplugin:cppunitassertequals" (and which then triggers lots of other
lopglugin:cppunitassertequal CPPUNIT_ASSERT -> CPPUNIT_ASSERT_EQUAL warnings).
For two css::uno::Reference equality comparisons in cppu/qa/test_any.cxx, it
was more straightforward to rewrite them with an explicit call to operator ==
(which silences loplugin:cppunitassertequal) than to adapt them to
CPPUNIT_ASSERT_EQUAL's requirement for arguments of identical types.
In sc/qa/unit/ucalc_pivottable.cxx, ScDPItemData needs toString, which has been
implemented trivially for now, but might want to combine that with the
DEBUG_PIVOT_TABLE-only ScDPItemData::Dump.
Change-Id: Iae6d09cf69bd4e52fe4411bba9e50c48e696291c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110546
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2export.cxx | 33 | ||||
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 24 |
2 files changed, 38 insertions, 19 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx index c8b4c03755e7..309381d80224 100644 --- a/chart2/qa/extras/chart2export.cxx +++ b/chart2/qa/extras/chart2export.cxx @@ -1817,11 +1817,13 @@ void Chart2ExportTest::testTitleManualLayoutXLSX() OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:x", "val"); double nX = aXVal.toDouble(); - CPPUNIT_ASSERT(nX > 0 && nX < 1); + CPPUNIT_ASSERT(nX > 0); + CPPUNIT_ASSERT(nX < 1); OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:layout/c:manualLayout/c:y", "val"); double nY = aYVal.toDouble(); - CPPUNIT_ASSERT(nY > 0 && nY < 1); + CPPUNIT_ASSERT(nY > 0); + CPPUNIT_ASSERT(nY < 1); CPPUNIT_ASSERT(nX != nY); assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:title/c:tx/c:rich/a:bodyPr", "rot", "1200000"); @@ -1839,20 +1841,24 @@ void Chart2ExportTest::testPlotAreaManualLayoutXLSX() OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:x", "val"); double nX = aXVal.toDouble(); - CPPUNIT_ASSERT(nX > 0 && nX < 1); + CPPUNIT_ASSERT(nX > 0); + CPPUNIT_ASSERT(nX < 1); OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:y", "val"); double nY = aYVal.toDouble(); - CPPUNIT_ASSERT(nY > 0 && nY < 1); + CPPUNIT_ASSERT(nY > 0); + CPPUNIT_ASSERT(nY < 1); CPPUNIT_ASSERT(nX != nY); OUString aWVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:w", "val"); double nW = aWVal.toDouble(); - CPPUNIT_ASSERT(nW > 0 && nW < 1); + CPPUNIT_ASSERT(nW > 0); + CPPUNIT_ASSERT(nW < 1); OUString aHVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:layout/c:manualLayout/c:h", "val"); double nH = aHVal.toDouble(); - CPPUNIT_ASSERT(nH > 0 && nH < 1); + CPPUNIT_ASSERT(nH > 0); + CPPUNIT_ASSERT(nH < 1); CPPUNIT_ASSERT(nH != nW); } @@ -1868,20 +1874,24 @@ void Chart2ExportTest::testLegendManualLayoutXLSX() OUString aXVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:x", "val"); double nX = aXVal.toDouble(); - CPPUNIT_ASSERT(nX > 0 && nX < 1); + CPPUNIT_ASSERT(nX > 0); + CPPUNIT_ASSERT(nX < 1); OUString aYVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:y", "val"); double nY = aYVal.toDouble(); - CPPUNIT_ASSERT(nY > 0 && nY < 1); + CPPUNIT_ASSERT(nY > 0); + CPPUNIT_ASSERT(nY < 1); CPPUNIT_ASSERT(nX != nY); OUString aWVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:w", "val"); double nW = aWVal.toDouble(); - CPPUNIT_ASSERT(nW > 0 && nW < 1); + CPPUNIT_ASSERT(nW > 0); + CPPUNIT_ASSERT(nW < 1); OUString aHVal = getXPath(pXmlDoc, "/c:chartSpace/c:chart/c:legend/c:layout/c:manualLayout/c:h", "val"); double nH = aHVal.toDouble(); - CPPUNIT_ASSERT(nH > 0 && nH < 1); + CPPUNIT_ASSERT(nH > 0); + CPPUNIT_ASSERT(nH < 1); CPPUNIT_ASSERT(nH != nW); // Make sure that default text font size is preserved after export @@ -2946,7 +2956,8 @@ void Chart2ExportTest::testTdf134255() CPPUNIT_ASSERT(xDataSeries.is()); Reference< beans::XPropertySet > xPropSet(xDataSeries, UNO_QUERY_THROW); bool bWrap = false; - CPPUNIT_ASSERT((xPropSet->getPropertyValue("TextWordWrap") >>= bWrap) && bWrap); + CPPUNIT_ASSERT((xPropSet->getPropertyValue("TextWordWrap") >>= bWrap)); + CPPUNIT_ASSERT(bWrap); // export test xmlDocUniquePtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text"); diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 57c7227b49c1..4b425a386b70 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -707,7 +707,8 @@ void Chart2ImportTest::testPPTXPercentageNumberFormats() Reference<beans::XPropertySet> xPS(xYAxis, uno::UNO_QUERY_THROW); bool bLinkNumberFormatToSource = true; bool bSuccess = xPS->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", bSuccess && !bLinkNumberFormatToSource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource); // FIXME: This should be in fact "0.00%". // see TODO in oox/source/drawingml/chart/modelbase.cxx @@ -1049,19 +1050,22 @@ void Chart2ImportTest::testTdf124817() xDataSeries = getDataSeriesFromDoc(xChartDoc, 0); CPPUNIT_ASSERT(xDataSeries.is()); uno::Reference<beans::XPropertySet> xPropSet_0(xDataSeries, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT((xPropSet_0->getPropertyValue("Symbol") >>= aSymblProp) && (aSymblProp.Style == chart2::SymbolStyle_NONE)); + CPPUNIT_ASSERT((xPropSet_0->getPropertyValue("Symbol") >>= aSymblProp)); + CPPUNIT_ASSERT_EQUAL(chart2::SymbolStyle_NONE, aSymblProp.Style); // Check the symbol of data series 2 (marker style square) xDataSeries = getDataSeriesFromDoc(xChartDoc, 1); CPPUNIT_ASSERT(xDataSeries.is()); uno::Reference<beans::XPropertySet> xPropSet_1(xDataSeries, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT((xPropSet_1->getPropertyValue("Symbol") >>= aSymblProp) && (aSymblProp.FillColor == static_cast<sal_Int32>(0xED7D31))); + CPPUNIT_ASSERT((xPropSet_1->getPropertyValue("Symbol") >>= aSymblProp)); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xED7D31), aSymblProp.FillColor); // Check the symbol of data series 3 (marker style diagonal cross) xDataSeries = getDataSeriesFromDoc(xChartDoc, 2); CPPUNIT_ASSERT(xDataSeries.is()); uno::Reference<beans::XPropertySet> xPropSet_2(xDataSeries, uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT((xPropSet_2->getPropertyValue("Symbol") >>= aSymblProp) && (aSymblProp.BorderColor == static_cast<sal_Int32>(0xFF0000))); + CPPUNIT_ASSERT((xPropSet_2->getPropertyValue("Symbol") >>= aSymblProp)); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xFF0000), aSymblProp.BorderColor); } void Chart2ImportTest::testTdf126033() @@ -1284,7 +1288,8 @@ void Chart2ImportTest::testNumberFormatsXLSX() bool bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; CPPUNIT_ASSERT_EQUAL(false, bSuccess); bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource); xPropertySet.set(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); xPropertySet->getPropertyValue("Label") >>= aLabel; @@ -1295,7 +1300,8 @@ void Chart2ImportTest::testNumberFormatsXLSX() bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; CPPUNIT_ASSERT_EQUAL(false, bSuccess); bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource); xPropertySet.set(xDataSeries->getDataPointByIndex(2), uno::UNO_SET_THROW); xPropertySet->getPropertyValue("Label") >>= aLabel; @@ -1306,7 +1312,8 @@ void Chart2ImportTest::testNumberFormatsXLSX() bSuccess = xPropertySet->getPropertyValue("PercentageNumberFormat") >>= nNumberFormat; CPPUNIT_ASSERT_EQUAL(false, bSuccess); bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource); } void Chart2ImportTest::testNumberFormatsDOCX() @@ -1371,7 +1378,8 @@ void Chart2ImportTest::testPercentageNumberFormatsDOCX() CPPUNIT_ASSERT_EQUAL(sal_False, aLabel.ShowNumber); CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumberInPercent); bool bSuccess = xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource; - CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess); + CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bLinkNumberFormatToSource); } void Chart2ImportTest::testAutoTitleDelDefaultValue2007XLSX() |