Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:05

0001 /*
0002  *  eventid_t.cppunit.cc
0003  *  CMSSW
0004  *
0005  *  Created by Chris Jones on 8/8/05.
0006  *
0007  */
0008 
0009 #include "cppunit/extensions/HelperMacros.h"
0010 
0011 #include "DataFormats/Provenance/interface/EventID.h"
0012 
0013 using namespace edm;
0014 
0015 class testEventID : public CppUnit::TestFixture {
0016   CPPUNIT_TEST_SUITE(testEventID);
0017 
0018   CPPUNIT_TEST(constructTest);
0019   CPPUNIT_TEST(comparisonTest);
0020   CPPUNIT_TEST(iterationTest);
0021 
0022   CPPUNIT_TEST_SUITE_END();
0023 
0024 public:
0025   void setUp() {}
0026   void tearDown() {}
0027 
0028   void constructTest();
0029   void comparisonTest();
0030   void iterationTest();
0031 };
0032 
0033 ///registration of the test so that the runner can find it
0034 CPPUNIT_TEST_SUITE_REGISTRATION(testEventID);
0035 
0036 void testEventID::constructTest() {
0037   EventID eventID;
0038   CPPUNIT_ASSERT(eventID.run() == 0U);
0039   CPPUNIT_ASSERT(eventID.luminosityBlock() == 0U);
0040   CPPUNIT_ASSERT(eventID.event() == 0U);
0041 
0042   const RunNumber_t rt = 3;
0043   const LuminosityBlockNumber_t lt = 2;
0044   const EventNumber_t et = 10123456789;
0045 
0046   EventID temp(rt, lt, et);
0047 
0048   CPPUNIT_ASSERT(temp.run() == rt);
0049   CPPUNIT_ASSERT(temp.luminosityBlock() == lt);
0050   CPPUNIT_ASSERT(temp.event() == et);
0051 
0052   CPPUNIT_ASSERT(EventID::maxRunNumber() == 0xFFFFFFFF);
0053   CPPUNIT_ASSERT(EventID::maxLuminosityBlockNumber() == 0xFFFFFFFF);
0054   CPPUNIT_ASSERT(EventID::maxEventNumber() == 0xFFFFFFFFFFFFFFFF);
0055 }
0056 
0057 void testEventID::comparisonTest() {
0058   const EventID small(1, 4, 1);
0059   const EventID med(2, 3, 2);
0060   const EventID med2(2, 3, 2);
0061   const EventID large(3, 1, 3);
0062   const EventID larger(3, 2, 1);
0063   const EventID largest(3, 2, 2);
0064 
0065   CPPUNIT_ASSERT(small < med);
0066   CPPUNIT_ASSERT(!(med < small));
0067   CPPUNIT_ASSERT(small <= med);
0068   CPPUNIT_ASSERT(!(small == med));
0069   CPPUNIT_ASSERT(small != med);
0070   CPPUNIT_ASSERT(!(small > med));
0071   CPPUNIT_ASSERT(!(small >= med));
0072 
0073   CPPUNIT_ASSERT(!(med <= small));
0074   CPPUNIT_ASSERT(!(med == small));
0075   CPPUNIT_ASSERT(med != small);
0076   CPPUNIT_ASSERT(med > small);
0077   CPPUNIT_ASSERT(med >= small);
0078 
0079   CPPUNIT_ASSERT(med2 == med);
0080   CPPUNIT_ASSERT(med2 <= med);
0081   CPPUNIT_ASSERT(med2 >= med);
0082   CPPUNIT_ASSERT(!(med2 != med));
0083   CPPUNIT_ASSERT(!(med2 < med));
0084   CPPUNIT_ASSERT(!(med2 > med));
0085 
0086   CPPUNIT_ASSERT(med < large);
0087   CPPUNIT_ASSERT(med <= large);
0088   CPPUNIT_ASSERT(!(med == large));
0089   CPPUNIT_ASSERT(med != large);
0090   CPPUNIT_ASSERT(!(med > large));
0091   CPPUNIT_ASSERT(!(med >= large));
0092 
0093   CPPUNIT_ASSERT(large < largest);
0094   CPPUNIT_ASSERT(!(largest < large));
0095   CPPUNIT_ASSERT(large <= largest);
0096   CPPUNIT_ASSERT(!(large == largest));
0097   CPPUNIT_ASSERT(large != largest);
0098   CPPUNIT_ASSERT(!(large > largest));
0099   CPPUNIT_ASSERT(!(large >= largest));
0100 
0101   CPPUNIT_ASSERT(larger < largest);
0102   CPPUNIT_ASSERT(!(largest < larger));
0103 }
0104 
0105 void testEventID::iterationTest() {
0106   EventID first = EventID::firstValidEvent();
0107 
0108   EventID second = first.next(1);
0109   CPPUNIT_ASSERT(first < second);
0110   CPPUNIT_ASSERT(first == (second.previous(1)));
0111 
0112   EventID run2(2, 1, 0);
0113   CPPUNIT_ASSERT(run2 < run2.nextRun(1));
0114   CPPUNIT_ASSERT(run2 > run2.previousRunLastEvent(1));
0115   CPPUNIT_ASSERT(first < run2.previousRunLastEvent(1));
0116   CPPUNIT_ASSERT(run2 < first.nextRunFirstEvent(1));
0117 
0118   EventID run2Last(2, 1, EventID::maxEventNumber());
0119   CPPUNIT_ASSERT(run2Last.next(1) == run2Last.nextRunFirstEvent(1));
0120 }