InputTag_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (InputTag_t)
2 #include "boost/test/unit_test.hpp"
3 
5 
6 #include <set>
7 #include <string>
8 
9 BOOST_AUTO_TEST_SUITE(InputTag_t)
10 BOOST_AUTO_TEST_CASE(InputTag_default_ctor)
11 {
14  BOOST_TEST(t.label() == empty);
15  BOOST_TEST(t.instance() == empty);
16  BOOST_TEST(t.process() == empty);
17 }
18 
19 BOOST_AUTO_TEST_CASE(InputTag_from_string)
20 {
22  std::string mylabel("thisIsMyLabel");
23  art::InputTag t(mylabel);
24  BOOST_TEST(t.label() == mylabel);
25  BOOST_TEST(t.instance() == empty);
26  BOOST_TEST(t.process() == empty);
27 }
28 
29 BOOST_AUTO_TEST_CASE(InputTag_from_two_strings)
30 {
32  std::string mylabel("thisIsMylabel");
33  std::string myinstance("someinstance");
34  art::InputTag t(mylabel, myinstance);
35  BOOST_TEST(t.label() == mylabel);
36  BOOST_TEST(t.instance() == myinstance);
37  BOOST_TEST(t.process() == empty);
38 }
39 
40 BOOST_AUTO_TEST_CASE(InputTag_from_three_strings)
41 {
42  std::string mylabel("thisIsMylabel");
43  std::string myinstance("someinstance");
44  std::string myprocess("aprocess");
45  art::InputTag t(mylabel, myinstance, myprocess);
46  BOOST_TEST(t.label() == mylabel);
47  BOOST_TEST(t.instance() == myinstance);
48  BOOST_TEST(t.process() == myprocess);
49 }
50 
51 BOOST_AUTO_TEST_CASE(InputTag_from_one_cstring)
52 {
53  const char* mylabel = "mylabel";
55  art::InputTag t(mylabel);
56  BOOST_TEST(t.label() == std::string(mylabel));
57  BOOST_TEST(t.instance() == empty);
58  BOOST_TEST(t.process() == empty);
59 }
60 
63 {
64  return t.label();
65 }
66 
67 BOOST_AUTO_TEST_CASE(InputTag_convert_from_string)
68 {
69  std::string mylabel("alabel");
70  std::string result = grabLabel(mylabel);
71  BOOST_TEST(mylabel == result);
72 }
73 
74 BOOST_AUTO_TEST_CASE(InputTag_convert_from_cstring)
75 {
76  const char* mylabel = "alabel";
77  std::string result = grabLabel(mylabel);
78  BOOST_TEST(std::string(mylabel) == result);
79 }
80 
81 BOOST_AUTO_TEST_CASE(InputTagEmptyFields_1)
82 {
83  art::InputTag a1("alabel::aprocess");
84  BOOST_TEST(a1.label() == std::string("alabel"));
85  BOOST_TEST(a1.instance() == std::string());
86  BOOST_TEST(a1.process() == std::string("aprocess"));
87 }
88 
89 BOOST_AUTO_TEST_CASE(InputTagEmptyFields_2)
90 {
91  art::InputTag a1(":aninstance:aprocess");
92  BOOST_TEST(a1.label() == std::string());
93  BOOST_TEST(a1.instance() == std::string("aninstance"));
94  BOOST_TEST(a1.process() == std::string("aprocess"));
95 }
96 
97 BOOST_AUTO_TEST_CASE(InputTagEmptyFields_3)
98 {
99  art::InputTag a1("alabel:aninstance:");
100  BOOST_TEST(a1.label() == std::string("alabel"));
101  BOOST_TEST(a1.instance() == std::string("aninstance"));
102  BOOST_TEST(a1.process() == std::string());
103 }
104 
105 BOOST_AUTO_TEST_CASE(InputTagEmptyFields_4)
106 {
107  art::InputTag a1("alabel:aninstance");
108  BOOST_TEST(a1.label() == std::string("alabel"));
109  BOOST_TEST(a1.instance() == std::string("aninstance"));
110  BOOST_TEST(a1.process() == std::string());
111 }
112 
113 BOOST_AUTO_TEST_CASE(InputTag_comparison)
114 {
115  art::InputTag const a1{"alabel:aname:aprocess"};
116  art::InputTag const a2{"alabel:aname:aprocess"};
117  auto const a3{a1};
118  art::InputTag const b1{"alabel:aname:anotherprocess"};
119  art::InputTag const b2{"alabel:anothername:aprocess"};
120  art::InputTag const b3{"anotherlabel:aname:aprocess"};
121  BOOST_TEST(a1 == a2);
122  BOOST_TEST(a1 == a3);
123  BOOST_TEST(a2 == a3);
124  BOOST_TEST(a3 == a1);
125  BOOST_TEST(a1 != b1);
126  BOOST_TEST(a1 != b2);
127  BOOST_TEST(a1 != b3);
128  BOOST_TEST(b1 != b2);
129  BOOST_TEST(b1 != b3);
130  BOOST_TEST(b2 != b3);
131 }
132 
133 BOOST_AUTO_TEST_CASE(InputTag_set)
134 {
135  std::set<art::InputTag> test;
136  test.emplace("c", "i");
137  test.emplace("a::");
138  test.emplace("b");
139 
140  std::vector<art::InputTag> const ref{"a::", "b", "c:i:"};
141  BOOST_TEST(test == ref, boost::test_tools::per_element{});
142 
143  // Test that an already present InputTag is not inserted again.
144  BOOST_TEST(test.emplace("c:i").second == false);
145 }
146 
147 BOOST_AUTO_TEST_SUITE_END()
static QCString result
std::string string
Definition: nybbler.cc:12
BOOST_AUTO_TEST_CASE(InputTag_default_ctor)
Definition: InputTag_t.cc:10
std::string const & instance() const noexcept
Definition: InputTag.cc:85
std::string const & process() const noexcept
Definition: InputTag.cc:91
std::string const & label() const noexcept
Definition: InputTag.cc:79
#define a2
#define a3
decltype(auto) constexpr empty(T &&obj)
ADL-aware version of std::empty.
Definition: StdUtils.h:97
#define a1
std::string grabLabel(art::InputTag const &t)
Definition: InputTag_t.cc:62