EventRange_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (EventRange_t)
2 #include "boost/test/unit_test.hpp"
4 
5 #include <sstream>
6 #include <string>
7 
8 using art::EventRange;
9 using namespace std::string_literals;
10 
11 // The EventRange class has member functions with names that are
12 // indicative of a collection. To disable collection comparison, we
13 // specialize the following Boost template. This suggests that the
14 // EventRange interface should be adjusted.
15 
16 namespace boost::unit_test {
17  template <>
18  struct is_forward_iterable<EventRange> {};
19 }
20 
21 BOOST_AUTO_TEST_SUITE(EventRange_t)
22 
24 {
25  auto er = EventRange::forSubRun(134);
26  BOOST_TEST(er.is_valid());
27  BOOST_TEST(er.is_full_subRun());
28  BOOST_TEST(er.contains(er.subRun(), 17));
29  std::ostringstream oss;
30  oss << er;
31  BOOST_TEST(oss.str() == "SubRun: 134 (full sub-run)"s);
32 }
33 
35 {
36  EventRange er1{1, 2, 4};
37  EventRange er2{1, 3, 6};
38  BOOST_TEST(!er1.merge(er2));
39  BOOST_TEST(!er1.is_disjoint(er2));
40  BOOST_TEST(er1.is_valid());
41  BOOST_TEST(!er1.is_full_subRun());
42 }
43 
45 {
46  EventRange er1{1, 2, 4};
47  EventRange const er2{1, 4, 6};
48  BOOST_TEST(er1.is_adjacent(er2));
49  BOOST_TEST(er1.is_disjoint(er2));
50  BOOST_TEST(er1.merge(er2));
51 
52  EventRange const ref{1, 2, 6};
53  BOOST_TEST(er1 == ref);
54  std::ostringstream oss;
55  oss << ref;
56  BOOST_TEST(oss.str() == "SubRun: 1 Event range: [2,6)"s);
57 
58  BOOST_TEST(er1.contains(1, 2));
59  BOOST_TEST(er1.contains(1, 4));
60  BOOST_TEST(!er1.contains(1, 6));
61  BOOST_TEST(!er1.contains(2, 4));
62 }
63 
65 {
66  EventRange const er0{1, 1, 6};
67  EventRange const er1{1, 2, 4};
68  EventRange const er2{1, 2, 5};
69  EventRange const er3{2, 2, 5};
70  EventRange const er4{2, 6, 9};
71  BOOST_TEST(er0 < er1);
72  BOOST_TEST(er1 < er2);
73  BOOST_TEST(er2 < er3);
74  BOOST_TEST(er0.is_disjoint(er3));
75  BOOST_TEST(!er0.is_disjoint(er1));
76  BOOST_TEST(er3.is_disjoint(er4));
77 }
78 
80 {
81  EventRange const er0{1, 1, 6};
82  EventRange const er1{1, 2, 4};
83  BOOST_TEST(er1.is_subset(er0));
84  BOOST_TEST(!er1.is_superset(er0));
85  BOOST_TEST(!er0.is_subset(er1));
86  BOOST_TEST(er0.is_superset(er1));
87  BOOST_TEST(!er1.is_overlapping(er0));
88  BOOST_TEST(!er0.is_overlapping(er1));
89 }
90 
92 {
93  EventRange const er0{1, 1, 6};
94  EventRange const er1{1, 2, 8};
95  BOOST_TEST(!er1.is_subset(er0));
96  BOOST_TEST(!er1.is_superset(er0));
97  BOOST_TEST(!er0.is_subset(er1));
98  BOOST_TEST(!er0.is_superset(er1));
99  BOOST_TEST(er1.is_overlapping(er0));
100  BOOST_TEST(er0.is_overlapping(er1));
101 }
102 
103 BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE(fullSubRun)
Definition: EventRange_t.cc:23
bool lessThan(CluLen c1, CluLen c2)
constexpr auto fullSubRun()
static QCString * s
Definition: config.cpp:1042