Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /*
0002  *  eventrange_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/EventRange.h"
0012 #include "DataFormats/Provenance/interface/EventID.h"
0013 
0014 using namespace edm;
0015 
0016 class testEventRange : public CppUnit::TestFixture {
0017   CPPUNIT_TEST_SUITE(testEventRange);
0018 
0019   CPPUNIT_TEST(constructTest);
0020   CPPUNIT_TEST(comparisonTest);
0021   CPPUNIT_TEST(overlapTest);
0022   //   CPPUNIT_TEST(iterationTest);
0023 
0024   CPPUNIT_TEST_SUITE_END();
0025 
0026 public:
0027   void setUp() {}
0028   void tearDown() {}
0029 
0030   void constructTest();
0031   void comparisonTest();
0032   void overlapTest();
0033   //   void iterationTest();
0034 };
0035 
0036 ///registration of the test so that the runner can find it
0037 CPPUNIT_TEST_SUITE_REGISTRATION(testEventRange);
0038 
0039 void testEventRange::constructTest() {
0040   RunNumber_t const rb = 1;
0041   RunNumber_t const re = 2;
0042   EventNumber_t const lb{30123456789ull};
0043   EventNumber_t const le{40123456789ull};
0044 
0045   EventRange normal(rb, 1, lb, re, 1, le);
0046   EventRange maxed(rb, 1, 0, re, 1, 0);
0047 
0048   CPPUNIT_ASSERT(normal.startRun() == rb);
0049   CPPUNIT_ASSERT(normal.endRun() == re);
0050   CPPUNIT_ASSERT(normal.startEvent() == lb);
0051   CPPUNIT_ASSERT(normal.endEvent() == le);
0052   CPPUNIT_ASSERT(maxed.startEventID().event() == EventID::maxEventNumber());
0053   CPPUNIT_ASSERT(maxed.endEventID().event() == EventID::maxEventNumber());
0054 }
0055 
0056 void testEventRange::comparisonTest() {
0057   EventID const small(1, 1, 1);
0058   EventID const med(7, 1, 2);
0059   EventID const large(8, 1, 10);
0060   EventID const larger(10, 1, 1);
0061   EventRange const normal(5, 1, 1, 8, 1, 1);
0062   EventRange const maxed(5, 1, 1, 8, 1, 0);
0063 
0064   CPPUNIT_ASSERT(!contains(normal, small));
0065   CPPUNIT_ASSERT(contains(normal, med));
0066   CPPUNIT_ASSERT(!contains(normal, large));
0067   CPPUNIT_ASSERT(!contains(normal, larger));
0068 
0069   CPPUNIT_ASSERT(!contains(maxed, small));
0070   CPPUNIT_ASSERT(contains(maxed, med));
0071   CPPUNIT_ASSERT(contains(maxed, large));
0072   CPPUNIT_ASSERT(!contains(maxed, larger));
0073 }
0074 
0075 void testEventRange::overlapTest() {
0076   EventRange const normal(5, 1, 1, 8, 1, 1);
0077   EventRange const small(6, 1, 1, 7, 1, 1);
0078   EventRange const large(3, 1, 1, 10, 1, 1);
0079   EventRange const early(3, 1, 1, 6, 1, 1);
0080   EventRange const late(7, 1, 1, 10, 1, 1);
0081 
0082   CPPUNIT_ASSERT(contains(normal, normal));
0083   CPPUNIT_ASSERT(contains(normal, small));
0084   CPPUNIT_ASSERT(!contains(normal, large));
0085   CPPUNIT_ASSERT(!contains(normal, early));
0086   CPPUNIT_ASSERT(!contains(normal, late));
0087   CPPUNIT_ASSERT(!contains(small, normal));
0088   CPPUNIT_ASSERT(contains(small, small));
0089   CPPUNIT_ASSERT(!contains(small, large));
0090   CPPUNIT_ASSERT(!contains(small, early));
0091   CPPUNIT_ASSERT(!contains(small, late));
0092   CPPUNIT_ASSERT(contains(large, normal));
0093   CPPUNIT_ASSERT(contains(large, small));
0094   CPPUNIT_ASSERT(contains(large, large));
0095   CPPUNIT_ASSERT(contains(large, early));
0096   CPPUNIT_ASSERT(contains(large, late));
0097   CPPUNIT_ASSERT(!contains(early, normal));
0098   CPPUNIT_ASSERT(!contains(early, small));
0099   CPPUNIT_ASSERT(!contains(early, large));
0100   CPPUNIT_ASSERT(contains(early, early));
0101   CPPUNIT_ASSERT(!contains(early, late));
0102   CPPUNIT_ASSERT(!contains(late, normal));
0103   CPPUNIT_ASSERT(!contains(late, small));
0104   CPPUNIT_ASSERT(!contains(late, large));
0105   CPPUNIT_ASSERT(!contains(late, early));
0106   CPPUNIT_ASSERT(contains(late, late));
0107   CPPUNIT_ASSERT(overlaps(normal, normal));
0108   CPPUNIT_ASSERT(overlaps(normal, small));
0109   CPPUNIT_ASSERT(overlaps(normal, large));
0110   CPPUNIT_ASSERT(overlaps(normal, early));
0111   CPPUNIT_ASSERT(overlaps(normal, late));
0112   CPPUNIT_ASSERT(overlaps(small, normal));
0113   CPPUNIT_ASSERT(overlaps(small, small));
0114   CPPUNIT_ASSERT(overlaps(small, large));
0115   CPPUNIT_ASSERT(overlaps(small, early));
0116   CPPUNIT_ASSERT(overlaps(small, late));
0117   CPPUNIT_ASSERT(overlaps(large, normal));
0118   CPPUNIT_ASSERT(overlaps(large, small));
0119   CPPUNIT_ASSERT(overlaps(large, large));
0120   CPPUNIT_ASSERT(overlaps(large, early));
0121   CPPUNIT_ASSERT(overlaps(large, late));
0122   CPPUNIT_ASSERT(overlaps(early, normal));
0123   CPPUNIT_ASSERT(overlaps(early, small));
0124   CPPUNIT_ASSERT(overlaps(early, large));
0125   CPPUNIT_ASSERT(overlaps(early, early));
0126   CPPUNIT_ASSERT(!overlaps(early, late));
0127   CPPUNIT_ASSERT(overlaps(late, normal));
0128   CPPUNIT_ASSERT(overlaps(late, small));
0129   CPPUNIT_ASSERT(overlaps(late, large));
0130   CPPUNIT_ASSERT(!overlaps(late, early));
0131   CPPUNIT_ASSERT(overlaps(late, late));
0132   CPPUNIT_ASSERT(distinct(early, late));
0133   CPPUNIT_ASSERT(distinct(late, early));
0134 }