pointer check in unit tests

Regina Henschel rb.henschel at t-online.de
Mon Nov 2 18:52:54 UTC 2020


Hi all,

In a unit test I have often sequences like this:

ScDocShellRef xDocSh = loadDoc("tdf137020_FlipVertical.", FORMAT_ODS);
CPPUNIT_ASSERT_MESSAGE("Failed to load tdf137020_FlipVertical.ods", 
xDocSh.is());
ScDocument& rDoc = xDocSh->GetDocument();
ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
CPPUNIT_ASSERT_MESSAGE("No SdDrawLayer", pDrawLayer);
SdrPage* pPage = pDrawLayer->GetPage(0);
CPPUNIT_ASSERT_MESSAGE("No draw page", pPage);
CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), pPage->GetObjCount() );
SdrObject* pObj =  pPage->GetObj(0);
CPPUNIT_ASSERT_MESSAGE("No object", pObj);

Can I drop the CPPUNIT_ASSERT in these cases? They have nothing to do 
with the test itself, but check only the pointers, which appear on the 
way to the object, which I want to test.

Kind regards
Regina


More information about the LibreOffice mailing list