EventID_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE(EventID_t)
2 #include "boost/test/unit_test.hpp"
3 
5 
6 using namespace art;
7 
8 BOOST_AUTO_TEST_SUITE(EventID_t)
9 
10 BOOST_AUTO_TEST_CASE(DefaultConstruction)
11 {
12  EventID def;
13  BOOST_TEST(!def.isValid());
14  BOOST_TEST(!def.subRunID().isValid());
15  BOOST_TEST(!def.runID().isValid());
16 }
17 
18 BOOST_AUTO_TEST_CASE(FullSpecConstruction)
19 {
20  EventNumber_t const et = 1;
21  RunNumber_t const rt = 2;
22  SubRunNumber_t const srt = 5;
23  EventID good(rt, srt, et);
24  BOOST_TEST(good.run() == rt);
25  BOOST_TEST(good.subRun() == srt);
26  BOOST_TEST(good.event() == et);
27 }
28 
30 {
32  BOOST_TEST(f.isValid());
33  BOOST_TEST(f.isFlush());
34  BOOST_TEST(f.subRunID().isFlush());
35  BOOST_TEST(f.runID().isFlush());
36 
38  BOOST_TEST(fs.isValid());
39  BOOST_TEST(fs.isFlush());
40  BOOST_TEST(fs.subRunID().isFlush());
41  BOOST_TEST(!fs.runID().isFlush());
42  BOOST_TEST(fs.run() == RunID::firstRun().run());
43 
44  BOOST_REQUIRE_THROW(EventID(f.run(), f.subRun(), f.event()), art::Exception);
45 }
46 
48 {
49  EventID const small(1, 1, 1);
50  EventID const med(2, 2, 2);
51  EventID const med2(2, 2, 2);
52  EventID const large(3, 3, 2);
53  EventID const largest(3, 3, 3);
54  BOOST_TEST(small < med);
55  BOOST_TEST(small <= med);
56  BOOST_TEST(!(small == med));
57  BOOST_TEST(small != med);
58  BOOST_TEST(!(small > med));
59  BOOST_TEST(!(small >= med));
60  BOOST_TEST(med2 == med);
61  BOOST_TEST(med2 <= med);
62  BOOST_TEST(med2 >= med);
63  BOOST_TEST(!(med2 != med));
64  BOOST_TEST(!(med2 < med));
65  BOOST_TEST(!(med2 > med));
66  BOOST_TEST(med < large);
67  BOOST_TEST(med <= large);
68  BOOST_TEST(!(med == large));
69  BOOST_TEST(med != large);
70  BOOST_TEST(!(med > large));
71  BOOST_TEST(!(med >= large));
72  BOOST_TEST(large < largest);
73  BOOST_TEST(large <= largest);
74  BOOST_TEST(!(large == largest));
75  BOOST_TEST(large != largest);
76  BOOST_TEST(!(large > largest));
77  BOOST_TEST(!(large >= largest));
78 }
79 
81 {
82  EventID first = EventID::firstEvent();
83  EventID second = first.next();
84  BOOST_TEST(first < second);
85  BOOST_TEST(first == (second.previous()));
86  EventID run2(2, 1, 1);
87  BOOST_TEST(run2 < run2.nextRun());
88  BOOST_TEST(run2 < run2.nextSubRun());
89 
91  BOOST_TEST(largeEvent.isValid());
92  EventID next(largeEvent.next());
93  BOOST_TEST(SubRunID::firstSubRun().next() == next.subRunID());
94  BOOST_TEST(next.event() == EventID::firstEvent().event());
95  BOOST_TEST(next.isValid());
96  BOOST_TEST(!next.isFlush());
97 }
98 
99 BOOST_AUTO_TEST_CASE(AllowConstructedZeroEvent)
100 {
101  EventID e1(3u, 0u, 0u);
102  BOOST_TEST(e1.event() == 0u);
103  EventID e2(SubRunID(3u, 0u), 0u);
104  BOOST_TEST(e2.event() == 0u);
105  BOOST_TEST(e2.nextSubRun(0u).event() == 0u);
106 }
107 
108 BOOST_AUTO_TEST_SUITE_END()
EventID previous() const
Definition: EventID.h:159
bool isValid() const
Definition: EventID.h:122
RunID const & runID() const
Definition: EventID.h:92
bool isFlush() const
Definition: RunID.h:76
static constexpr EventID flushEvent() noexcept
Definition: EventID.h:221
SubRunID const & subRunID() const
Definition: EventID.h:104
EventID next() const
Definition: EventID.h:134
static constexpr double fs
Definition: Units.h:100
static EventID maxEvent()
Definition: EventID.h:184
bool isFlush() const
Definition: EventID.h:128
RunNumber_t run() const
Definition: RunID.h:64
RunNumber_t run() const
Definition: EventID.h:98
bool isValid() const
Definition: SubRunID.h:97
BOOST_AUTO_TEST_CASE(DefaultConstruction)
Definition: EventID_t.cc:10
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
EventID nextSubRun(EventNumber_t first=IDNumber< Level::Event >::first()) const
Definition: EventID.h:147
static SubRunID firstSubRun()
Definition: SubRunID.h:153
bool isFlush() const
Definition: SubRunID.h:103
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
bool isValid() const
Definition: RunID.h:70
EventNumber_t event() const
Definition: EventID.h:116
static RunID firstRun()
Definition: RunID.h:116
EventID nextRun() const
Definition: EventID.h:153
static EventID firstEvent()
Definition: EventID.h:190
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
SubRunNumber_t subRun() const
Definition: EventID.h:110
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120