Skip to content

Commit

Permalink
Hide the fact that the expression values are irrelevant for the unit …
Browse files Browse the repository at this point in the history
…test

clang was complaining that the values generated by the expressions passed to
CPPUNIT_ASSERT_THROW were never used. That is expected since they are
supposed to thrown an exception. Slightly reworking the expression
solved that problem.
  • Loading branch information
Dr15Jones committed Oct 6, 2014
1 parent 7e5e5cf commit 4f96191
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
42 changes: 21 additions & 21 deletions FWCore/FWLite/test/ref_t.cppunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,29 +388,29 @@ void testRefInROOT::testThinning() {

CPPUNIT_ASSERT(trackD.refVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.refVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.refVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.refVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackD.refVector1.isAvailable());
CPPUNIT_ASSERT(trackD.refVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.refVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.refVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.refVector1[8].operator->(), cms::Exception);

CPPUNIT_ASSERT(trackD.ptrVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.ptrVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.ptrVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.ptrVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackD.ptrVector1[9]->a == 21 + offset);
CPPUNIT_ASSERT(!trackD.ptrVector1.isAvailable());
CPPUNIT_ASSERT(trackD.ptrVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.ptrVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.ptrVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.ptrVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackD.ptrVector1[9]->a == 21 + offset);

CPPUNIT_ASSERT(trackD.refToBaseVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.refToBaseVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.refToBaseVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.refToBaseVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackD.refToBaseVector1.isAvailable());
CPPUNIT_ASSERT(trackD.refToBaseVector1[0]->a == 10 + offset);
CPPUNIT_ASSERT(trackD.refToBaseVector1[4]->a == 14 + offset);
CPPUNIT_ASSERT_THROW(trackD.refToBaseVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackD.refToBaseVector1[8].operator->(), cms::Exception);

// In the G branch this tests accessing a value in
// thinned collection made from a master collection.
Expand Down Expand Up @@ -462,11 +462,11 @@ void testRefInROOT::testThinning() {

edmtest::TrackOfThings const& trackM0 = vTracks->at(0);
CPPUNIT_ASSERT(!trackM0.ref1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM0.ref1->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM0.ref1.operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackM0.ptr1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM0.ptr1->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM0.ptr1.operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackM0.refToBase1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM0.refToBase1->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM0.refToBase1.operator->(), cms::Exception);

edmtest::TrackOfThings const& trackM1 = vTracks->at(1);
CPPUNIT_ASSERT(trackM1.ref1.isAvailable());
Expand All @@ -477,29 +477,29 @@ void testRefInROOT::testThinning() {
CPPUNIT_ASSERT(trackM1.refToBase1->a == 44 + offset);

edmtest::TrackOfThings const& trackM = vTracks->at(0);
CPPUNIT_ASSERT_THROW(trackM.refVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.refVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.refVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackM.refVector1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM.refVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.refVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.refVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refVector1[8].operator->(), cms::Exception);

CPPUNIT_ASSERT_THROW(trackM.ptrVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.ptrVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackM.ptrVector1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.ptrVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.ptrVector1[8].operator->(), cms::Exception);

CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.refToBaseVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[8].operator->(), cms::Exception);
CPPUNIT_ASSERT(!trackM.refToBaseVector1.isAvailable());
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[0]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[0].operator->(), cms::Exception);
CPPUNIT_ASSERT(trackM.refToBaseVector1[4]->a == 44 + offset);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[8]->a, cms::Exception);
CPPUNIT_ASSERT_THROW(trackM.refToBaseVector1[8].operator->(), cms::Exception);
}
}

Expand Down
10 changes: 5 additions & 5 deletions FWCore/Framework/test/iovsyncvalue_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ testIOVSyncValue::invalidComparisonTest()

CPPUNIT_ASSERT(! timeBased.comparable(eventBased));
CPPUNIT_ASSERT(! eventBased.comparable(timeBased));
CPPUNIT_ASSERT_THROW( (timeBased < eventBased) , cms::Exception);
CPPUNIT_ASSERT_THROW( (timeBased <= eventBased) , cms::Exception);
CPPUNIT_ASSERT_THROW( [&](){return timeBased < eventBased;}() , cms::Exception);
CPPUNIT_ASSERT_THROW( [&](){return timeBased <= eventBased;}() , cms::Exception);
CPPUNIT_ASSERT( !(timeBased == eventBased));
CPPUNIT_ASSERT( (timeBased != eventBased));
CPPUNIT_ASSERT_THROW( (timeBased > eventBased) , cms::Exception);
CPPUNIT_ASSERT_THROW( (timeBased >= eventBased) , cms::Exception);
CPPUNIT_ASSERT( timeBased != eventBased);
CPPUNIT_ASSERT_THROW( [&]() {return timeBased > eventBased;}() , cms::Exception);
CPPUNIT_ASSERT_THROW( [&]() {return timeBased >= eventBased;}() , cms::Exception);
}

0 comments on commit 4f96191

Please sign in to comment.