1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
* eventid_t.cppunit.cc
* CMSSW
*
* Created by Chris Jones on 8/8/05.
*
*/
#include "cppunit/extensions/HelperMacros.h"
#include "DataFormats/Provenance/interface/EventID.h"
using namespace edm;
class testEventID : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(testEventID);
CPPUNIT_TEST(constructTest);
CPPUNIT_TEST(comparisonTest);
CPPUNIT_TEST(iterationTest);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void constructTest();
void comparisonTest();
void iterationTest();
};
///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(testEventID);
void testEventID::constructTest() {
EventID eventID;
CPPUNIT_ASSERT(eventID.run() == 0U);
CPPUNIT_ASSERT(eventID.luminosityBlock() == 0U);
CPPUNIT_ASSERT(eventID.event() == 0U);
const RunNumber_t rt = 3;
const LuminosityBlockNumber_t lt = 2;
const EventNumber_t et = 10123456789;
EventID temp(rt, lt, et);
CPPUNIT_ASSERT(temp.run() == rt);
CPPUNIT_ASSERT(temp.luminosityBlock() == lt);
CPPUNIT_ASSERT(temp.event() == et);
CPPUNIT_ASSERT(EventID::maxRunNumber() == 0xFFFFFFFF);
CPPUNIT_ASSERT(EventID::maxLuminosityBlockNumber() == 0xFFFFFFFF);
CPPUNIT_ASSERT(EventID::maxEventNumber() == 0xFFFFFFFFFFFFFFFF);
}
void testEventID::comparisonTest() {
const EventID small(1, 4, 1);
const EventID med(2, 3, 2);
const EventID med2(2, 3, 2);
const EventID large(3, 1, 3);
const EventID larger(3, 2, 1);
const EventID largest(3, 2, 2);
CPPUNIT_ASSERT(small < med);
CPPUNIT_ASSERT(!(med < small));
CPPUNIT_ASSERT(small <= med);
CPPUNIT_ASSERT(!(small == med));
CPPUNIT_ASSERT(small != med);
CPPUNIT_ASSERT(!(small > med));
CPPUNIT_ASSERT(!(small >= med));
CPPUNIT_ASSERT(!(med <= small));
CPPUNIT_ASSERT(!(med == small));
CPPUNIT_ASSERT(med != small);
CPPUNIT_ASSERT(med > small);
CPPUNIT_ASSERT(med >= small);
CPPUNIT_ASSERT(med2 == med);
CPPUNIT_ASSERT(med2 <= med);
CPPUNIT_ASSERT(med2 >= med);
CPPUNIT_ASSERT(!(med2 != med));
CPPUNIT_ASSERT(!(med2 < med));
CPPUNIT_ASSERT(!(med2 > med));
CPPUNIT_ASSERT(med < large);
CPPUNIT_ASSERT(med <= large);
CPPUNIT_ASSERT(!(med == large));
CPPUNIT_ASSERT(med != large);
CPPUNIT_ASSERT(!(med > large));
CPPUNIT_ASSERT(!(med >= large));
CPPUNIT_ASSERT(large < largest);
CPPUNIT_ASSERT(!(largest < large));
CPPUNIT_ASSERT(large <= largest);
CPPUNIT_ASSERT(!(large == largest));
CPPUNIT_ASSERT(large != largest);
CPPUNIT_ASSERT(!(large > largest));
CPPUNIT_ASSERT(!(large >= largest));
CPPUNIT_ASSERT(larger < largest);
CPPUNIT_ASSERT(!(largest < larger));
}
void testEventID::iterationTest() {
EventID first = EventID::firstValidEvent();
EventID second = first.next(1);
CPPUNIT_ASSERT(first < second);
CPPUNIT_ASSERT(first == (second.previous(1)));
EventID run2(2, 1, 0);
CPPUNIT_ASSERT(run2 < run2.nextRun(1));
CPPUNIT_ASSERT(run2 > run2.previousRunLastEvent(1));
CPPUNIT_ASSERT(first < run2.previousRunLastEvent(1));
CPPUNIT_ASSERT(run2 < first.nextRunFirstEvent(1));
EventID run2Last(2, 1, EventID::maxEventNumber());
CPPUNIT_ASSERT(run2Last.next(1) == run2Last.nextRunFirstEvent(1));
}
|