Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:36

0001 /*
0002  *  lumirange_t.cppunit.cc
0003  *  CMSSW
0004  *
0005  *  Created by Eric Vaandering December 2008.
0006  *
0007  */
0008 
0009 #include "cppunit/extensions/HelperMacros.h"
0010 
0011 #include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
0012 
0013 using namespace edm;
0014 
0015 class testLumiRange : public CppUnit::TestFixture {
0016   CPPUNIT_TEST_SUITE(testLumiRange);
0017 
0018   CPPUNIT_TEST(constructTest);
0019   CPPUNIT_TEST(comparisonTest);
0020   CPPUNIT_TEST(overlapTest);
0021 
0022   CPPUNIT_TEST_SUITE_END();
0023 
0024 public:
0025   void setUp() {}
0026   void tearDown() {}
0027 
0028   void constructTest();
0029   void comparisonTest();
0030   void overlapTest();
0031 };
0032 
0033 ///registration of the test so that the runner can find it
0034 CPPUNIT_TEST_SUITE_REGISTRATION(testLumiRange);
0035 
0036 void testLumiRange::constructTest() {
0037   const RunNumber_t rb = 1;
0038   const RunNumber_t re = 2;
0039   const LuminosityBlockNumber_t lb = 3;
0040   const LuminosityBlockNumber_t le = 4;
0041 
0042   LuminosityBlockRange normal(rb, lb, re, le);
0043   LuminosityBlockRange maxed(rb, 0, re, 0);
0044   LuminosityBlockID dummy;
0045 
0046   CPPUNIT_ASSERT(normal.startRun() == rb);
0047   CPPUNIT_ASSERT(normal.endRun() == re);
0048   CPPUNIT_ASSERT(normal.startLumi() == lb);
0049   CPPUNIT_ASSERT(normal.endLumi() == le);
0050   CPPUNIT_ASSERT(maxed.startLumiID().luminosityBlock() == dummy.maxLuminosityBlockNumber());
0051   CPPUNIT_ASSERT(maxed.endLumiID().luminosityBlock() == dummy.maxLuminosityBlockNumber());
0052 }
0053 
0054 void testLumiRange::comparisonTest() {
0055   const LuminosityBlockID small(1, 1);
0056   const LuminosityBlockID med(7, 2);
0057   const LuminosityBlockID large(8, 10);
0058   const LuminosityBlockID larger(10, 1);
0059   const LuminosityBlockRange normal(5, 1, 8, 1);
0060   const LuminosityBlockRange maxed(5, 1, 8, 0);
0061 
0062   CPPUNIT_ASSERT(!contains(normal, small));
0063   CPPUNIT_ASSERT(contains(normal, med));
0064   CPPUNIT_ASSERT(!contains(normal, large));
0065   CPPUNIT_ASSERT(!contains(normal, larger));
0066 
0067   CPPUNIT_ASSERT(!contains(maxed, small));
0068   CPPUNIT_ASSERT(contains(maxed, med));
0069   CPPUNIT_ASSERT(contains(maxed, large));
0070   CPPUNIT_ASSERT(!contains(maxed, larger));
0071 }
0072 
0073 void testLumiRange::overlapTest() {
0074   const LuminosityBlockRange normal(5, 1, 8, 1);
0075   const LuminosityBlockRange small(6, 1, 7, 1);
0076   const LuminosityBlockRange large(3, 1, 10, 1);
0077   const LuminosityBlockRange early(3, 1, 6, 1);
0078   const LuminosityBlockRange late(7, 1, 10, 1);
0079 
0080   CPPUNIT_ASSERT(contains(normal, normal));
0081   CPPUNIT_ASSERT(contains(normal, small));
0082   CPPUNIT_ASSERT(!contains(normal, large));
0083   CPPUNIT_ASSERT(!contains(normal, early));
0084   CPPUNIT_ASSERT(!contains(normal, late));
0085   CPPUNIT_ASSERT(!contains(small, normal));
0086   CPPUNIT_ASSERT(contains(small, small));
0087   CPPUNIT_ASSERT(!contains(small, large));
0088   CPPUNIT_ASSERT(!contains(small, early));
0089   CPPUNIT_ASSERT(!contains(small, late));
0090   CPPUNIT_ASSERT(contains(large, normal));
0091   CPPUNIT_ASSERT(contains(large, small));
0092   CPPUNIT_ASSERT(contains(large, large));
0093   CPPUNIT_ASSERT(contains(large, early));
0094   CPPUNIT_ASSERT(contains(large, late));
0095   CPPUNIT_ASSERT(!contains(early, normal));
0096   CPPUNIT_ASSERT(!contains(early, small));
0097   CPPUNIT_ASSERT(!contains(early, large));
0098   CPPUNIT_ASSERT(contains(early, early));
0099   CPPUNIT_ASSERT(!contains(early, late));
0100   CPPUNIT_ASSERT(!contains(late, normal));
0101   CPPUNIT_ASSERT(!contains(late, small));
0102   CPPUNIT_ASSERT(!contains(late, large));
0103   CPPUNIT_ASSERT(!contains(late, early));
0104   CPPUNIT_ASSERT(contains(late, late));
0105   CPPUNIT_ASSERT(overlaps(normal, normal));
0106   CPPUNIT_ASSERT(overlaps(normal, small));
0107   CPPUNIT_ASSERT(overlaps(normal, large));
0108   CPPUNIT_ASSERT(overlaps(normal, early));
0109   CPPUNIT_ASSERT(overlaps(normal, late));
0110   CPPUNIT_ASSERT(overlaps(small, normal));
0111   CPPUNIT_ASSERT(overlaps(small, small));
0112   CPPUNIT_ASSERT(overlaps(small, large));
0113   CPPUNIT_ASSERT(overlaps(small, early));
0114   CPPUNIT_ASSERT(overlaps(small, late));
0115   CPPUNIT_ASSERT(overlaps(large, normal));
0116   CPPUNIT_ASSERT(overlaps(large, small));
0117   CPPUNIT_ASSERT(overlaps(large, large));
0118   CPPUNIT_ASSERT(overlaps(large, early));
0119   CPPUNIT_ASSERT(overlaps(large, late));
0120   CPPUNIT_ASSERT(overlaps(early, normal));
0121   CPPUNIT_ASSERT(overlaps(early, small));
0122   CPPUNIT_ASSERT(overlaps(early, large));
0123   CPPUNIT_ASSERT(overlaps(early, early));
0124   CPPUNIT_ASSERT(!overlaps(early, late));
0125   CPPUNIT_ASSERT(overlaps(late, normal));
0126   CPPUNIT_ASSERT(overlaps(late, small));
0127   CPPUNIT_ASSERT(overlaps(late, large));
0128   CPPUNIT_ASSERT(!overlaps(late, early));
0129   CPPUNIT_ASSERT(overlaps(late, late));
0130 }
0131 
0132 // void testEventID::iterationTest() {
0133 //    EventID first = EventID::firstValidEvent();
0134 //
0135 //    EventID second = first.next();
0136 //    CPPUNIT_ASSERT(first < second);
0137 //    CPPUNIT_ASSERT(first == (second.previous()));
0138 //
0139 //    EventID run2(2, 0);
0140 //    CPPUNIT_ASSERT(run2 < run2.nextRun());
0141 //    CPPUNIT_ASSERT(run2 > run2.previousRunLastEvent());
0142 //    CPPUNIT_ASSERT(first < run2.previousRunLastEvent());
0143 //    CPPUNIT_ASSERT(run2 < first.nextRunFirstEvent());
0144 //
0145 //    EventID run2Last(2, EventID::maxEventNumber());
0146 //    CPPUNIT_ASSERT(run2Last.next() == run2Last.nextRunFirstEvent());
0147 // }