Classes | Namespaces | Macros | Functions
EventRange_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "canvas/Persistency/Provenance/EventRange.h"
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

struct  boost::unit_test::is_forward_iterable< EventRange >
 

Namespaces

 boost::unit_test
 

Macros

#define BOOST_TEST_MODULE   (EventRange_t)
 

Functions

 BOOST_AUTO_TEST_CASE (fullSubRun)
 
 BOOST_AUTO_TEST_CASE (merge1)
 
 BOOST_AUTO_TEST_CASE (merge2)
 
 BOOST_AUTO_TEST_CASE (lessThan)
 
 BOOST_AUTO_TEST_CASE (traits1)
 
 BOOST_AUTO_TEST_CASE (traits2)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (EventRange_t)

Definition at line 1 of file EventRange_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( fullSubRun  )

Definition at line 23 of file EventRange_t.cc.

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 }
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( merge1  )

Definition at line 34 of file EventRange_t.cc.

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 }
BOOST_AUTO_TEST_CASE ( merge2  )

Definition at line 44 of file EventRange_t.cc.

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 }
static QCString * s
Definition: config.cpp:1042
BOOST_AUTO_TEST_CASE ( lessThan  )

Definition at line 64 of file EventRange_t.cc.

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 }
BOOST_AUTO_TEST_CASE ( traits1  )

Definition at line 79 of file EventRange_t.cc.

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 }
BOOST_AUTO_TEST_CASE ( traits2  )

Definition at line 91 of file EventRange_t.cc.

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 }