summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-02-08 07:48:59 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-02-08 09:15:01 +0100
commit6b00d0576a310796590631d14c54d7d5ea6814ac (patch)
tree2e11a4454592be39cfeaa68458cae964d8cdef5e /vcl/qa
parent17149f65f03a34e88bb4a10abcd20e6891f5d7ca (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 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx7
-rw-r--r--vcl/qa/cppunit/canvasbitmaptest.cxx22
-rw-r--r--vcl/qa/cppunit/lifecycle.cxx5
-rw-r--r--vcl/qa/cppunit/timer.cxx3
4 files changed, 26 insertions, 11 deletions
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index bbf8a38da0f6..a4852438f6f3 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -76,8 +76,8 @@ void BitmapRenderTest::testTdf104141()
// Check drawing results: ensure that it contains transparent
// (greenish) pixels
const Color aColor = pVDev->GetPixel(Point(21, 21));
- CPPUNIT_ASSERT(aColor.GetGreen() > 10 * aColor.GetRed()
- && aColor.GetGreen() > 10 * aColor.GetBlue());
+ CPPUNIT_ASSERT(aColor.GetGreen() > 10 * aColor.GetRed());
+ CPPUNIT_ASSERT(aColor.GetGreen() > 10 * aColor.GetBlue());
}
void BitmapRenderTest::testTdf113918()
@@ -101,7 +101,8 @@ void BitmapRenderTest::testTdf113918()
// Ensure that image is drawn with gray text color from palette
const Color aColor = pVDev->GetPixel(Point(1298, 1368));
- CPPUNIT_ASSERT(aColor.GetGreen() == aColor.GetRed() && aColor.GetGreen() == aColor.GetBlue());
+ CPPUNIT_ASSERT_EQUAL(aColor.GetGreen(), aColor.GetRed());
+ CPPUNIT_ASSERT_EQUAL(aColor.GetGreen(), aColor.GetBlue());
CPPUNIT_ASSERT(aColor.GetGreen() > 100);
}
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index 658444dee9f5..a26296a7b5e8 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -96,8 +96,10 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size not (200,200)",
Size(200,200), aContainedBmp.GetSizePixel());
- CPPUNIT_ASSERT_MESSAGE( "Original bitmap size via API not (200,200)",
- xBmp->getSize().Width == 200 && xBmp->getSize().Height == 200);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size via API not (200,200)",
+ sal_Int32(200), xBmp->getSize().Width);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Original bitmap size via API not (200,200)",
+ sal_Int32(200), xBmp->getSize().Height);
CPPUNIT_ASSERT_EQUAL_MESSAGE( "alpha state mismatch",
aContainedBmpEx.IsTransparent(), bool(xBmp->hasAlpha()));
@@ -168,8 +170,12 @@ void checkCanvasBitmap( const rtl::Reference<VclCanvasBitmap>& xBmp,
0.0, pARGBStart[0].Alpha);
}
- CPPUNIT_ASSERT_MESSAGE( "Second pixel is not black",
- pRGBStart[1].Red == 0.0 && pRGBStart[1].Green == 0.0 && pRGBStart[1].Blue == 0.0);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
+ 0.0, pRGBStart[1].Red);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
+ 0.0, pRGBStart[1].Green);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second pixel is not black",
+ 0.0, pRGBStart[1].Blue);
if( nOriginalDepth > 8 )
{
@@ -347,7 +353,9 @@ private:
CPPUNIT_ASSERT_MESSAGE( "Got palette getIndex interface call without handing out palette",
getPalette().is() );
CPPUNIT_ASSERT_MESSAGE( "getIndex: index out of range",
- nIndex >= 0 && nIndex < 256 );
+ nIndex >= 0 );
+ CPPUNIT_ASSERT_MESSAGE( "getIndex: index out of range",
+ nIndex < 256 );
entry = colorToStdColorSpaceSequence(
Color(sal_uInt8(nIndex),
sal_uInt8(nIndex),
@@ -363,7 +371,9 @@ private:
CPPUNIT_ASSERT_MESSAGE( "Got palette setIndex interface call without handing out palette",
getPalette().is());
CPPUNIT_ASSERT_MESSAGE( "setIndex: index out of range",
- nIndex >= 0 && nIndex < 256);
+ nIndex >= 0);
+ CPPUNIT_ASSERT_MESSAGE( "setIndex: index out of range",
+ nIndex < 256);
return false;
}
diff --git a/vcl/qa/cppunit/lifecycle.cxx b/vcl/qa/cppunit/lifecycle.cxx
index e25b03d279e4..6cdbbe0819d6 100644
--- a/vcl/qa/cppunit/lifecycle.cxx
+++ b/vcl/qa/cppunit/lifecycle.cxx
@@ -75,7 +75,10 @@ void LifecycleTest::testVirtualDevice()
ScopedVclPtrInstance< VirtualDevice > pVDev2;
VclPtrInstance<VirtualDevice> pVDev3;
VclPtrInstance<VirtualDevice> pVDev4(DeviceFormat::BITMASK);
- CPPUNIT_ASSERT(!!pVDev && !!pVDev2 && !!pVDev3 && !!pVDev4);
+ CPPUNIT_ASSERT(!!pVDev);
+ CPPUNIT_ASSERT(!!pVDev2);
+ CPPUNIT_ASSERT(!!pVDev3);
+ CPPUNIT_ASSERT(!!pVDev4);
pVDev.disposeAndClear();
pVDev4.disposeAndClear();
}
diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx
index 112e3f611b96..15493b953639 100644
--- a/vcl/qa/cppunit/timer.cxx
+++ b/vcl/qa/cppunit/timer.cxx
@@ -556,7 +556,8 @@ void TimerTest::testRoundRobin()
CPPUNIT_ASSERT( nCount1 <= 3 );
CPPUNIT_ASSERT( nCount2 <= 3 );
}
- CPPUNIT_ASSERT( 3 == nCount1 && 3 == nCount2 );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32(3), nCount1 );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt32(3), nCount2 );
}
CPPUNIT_TEST_SUITE_REGISTRATION(TimerTest);