#include "boost/test/unit_test.hpp"
#include "MockRun.h"
#include "cetlib/map_vector.h"
#include <map>
#include <memory>
#include <ostream>
#include <string>
#include <tuple>
#include <vector>
Go to the source code of this file.
#define BOOST_TEST_MODULE (Product aggregation Test) |
BOOST_AUTO_TEST_CASE |
( |
class_type |
| ) |
|
Definition at line 71 of file aggregate_t.cc.
74 r1.
put<HoursPerWorker>(HoursPerWorker{
"Sam", 12});
75 r1.
put<HoursPerWorker>(HoursPerWorker{
"Sam", 14});
76 auto sam = r1.
get<HoursPerWorker>();
77 BOOST_TEST(sam.name_ ==
"Sam");
78 BOOST_TEST(sam.hours_ == 26u);
81 r2.
put<HoursPerWorker>(HoursPerWorker{
"John", 8});
82 r2.
put<HoursPerWorker>(HoursPerWorker{
"Jim", 10});
83 auto john = r2.
get<HoursPerWorker>();
84 BOOST_TEST(john.name_ ==
"John");
85 BOOST_TEST(john.hours_ == 8u);
BOOST_AUTO_TEST_CASE |
( |
numbers |
| ) |
|
BOOST_AUTO_TEST_CASE |
( |
vector |
| ) |
|
Definition at line 96 of file aggregate_t.cc.
98 using nums_t = std::vector<int>;
100 r.
put<nums_t>(nums_t{1, 3, 5});
101 r.
put<nums_t>(nums_t{2, 4, 6});
102 auto ref = {1, 3, 5, 2, 4, 6};
103 BOOST_TEST(r.
get<nums_t>() == ref, boost::test_tools::per_element{});
BOOST_AUTO_TEST_CASE |
( |
list |
| ) |
|
Definition at line 106 of file aggregate_t.cc.
108 using chars_t = std::list<char>;
110 r.
put<chars_t>(chars_t{
'a',
'b',
'c'});
111 r.
put<chars_t>(chars_t{
'y',
'z'});
112 auto ref = {
'a',
'b',
'c',
'y',
'z'};
113 BOOST_TEST(r.
get<chars_t>() == ref, boost::test_tools::per_element{});
BOOST_AUTO_TEST_CASE |
( |
deque |
| ) |
|
Definition at line 116 of file aggregate_t.cc.
118 using nums_t = std::deque<unsigned>;
120 r.
put<nums_t>(nums_t{0, 5, 8});
121 r.
put<nums_t>(nums_t{1, 2, 4});
122 std::initializer_list<unsigned>
const ref{0u, 5u, 8u, 1u, 2u, 4u};
123 BOOST_TEST(r.
get<nums_t>() == ref, boost::test_tools::per_element{});
BOOST_AUTO_TEST_CASE |
( |
array |
| ) |
|
Definition at line 126 of file aggregate_t.cc.
128 using histo_t = std::array<int, 3>;
130 r.
put<histo_t>(histo_t{{1, 4, 7}});
131 r.
put<histo_t>(histo_t{{-1, 6, 92}});
132 auto ref = {0, 10, 99};
133 BOOST_TEST(r.
get<histo_t>() == ref, boost::test_tools::per_element{});
BOOST_AUTO_TEST_CASE |
( |
map |
| ) |
|
Definition at line 136 of file aggregate_t.cc.
138 using map_t = std::map<std::string, unsigned>;
139 map_t
const children{{
"Billy", 7}, {
"Josephine", 9}, {
"Gregory", 0}};
140 map_t
const adults{{
"Jennifer", 28}, {
"Gregory", 47}, {
"Ervin", 78}};
142 r.
put<map_t>(children);
143 r.
put<map_t>(adults);
144 map_t
const people{{
"Billy", 7},
149 BOOST_TEST(r.
get<map_t>() == people);
BOOST_AUTO_TEST_CASE |
( |
multimap |
| ) |
|
Definition at line 152 of file aggregate_t.cc.
154 using map_t = std::multimap<std::string, unsigned>;
155 map_t
const children{{
"Billy", 7}, {
"Josephine", 9}, {
"Gregory", 0}};
156 map_t
const adults{{
"Jennifer", 28}, {
"Gregory", 47}, {
"Ervin", 78}};
158 r.
put<map_t>(children);
159 r.
put<map_t>(adults);
160 map_t
const people{{
"Billy", 7},
166 BOOST_TEST(r.
get<map_t>() == people);
BOOST_AUTO_TEST_CASE |
( |
set |
| ) |
|
Definition at line 169 of file aggregate_t.cc.
171 using set_t = std::set<std::string>;
173 r.
put<set_t>(set_t{
"Brahms",
"Beethoven"});
174 r.
put<set_t>(set_t{
"Bach",
"Brahms"});
175 set_t
const composers{
"Bach",
"Beethoven",
"Brahms"};
176 BOOST_TEST(r.
get<set_t>() == composers);
BOOST_AUTO_TEST_CASE |
( |
pair |
| ) |
|
Definition at line 179 of file aggregate_t.cc.
181 using pair_t = std::pair<unsigned, double>;
183 r.
put<pair_t>(pair_t{0u, 14.});
184 r.
put<pair_t>(pair_t{6u, 20.});
186 BOOST_TEST(result.first == 6u);
187 BOOST_CHECK_CLOSE_FRACTION(result.second, 34.,
tolerance);
BOOST_AUTO_TEST_CASE |
( |
tuple |
| ) |
|
Definition at line 190 of file aggregate_t.cc.
192 using tuple_t = std::tuple<A, unsigned, double>;
194 r.
put<tuple_t>(tuple_t{
"run1"s, 3, 1.2});
195 r.
put<tuple_t>(tuple_t{
"run2"s, 74, 2.9});
197 BOOST_TEST(std::get<A>(result).name_ ==
"run1");
198 BOOST_TEST(std::get<unsigned>(result) == 77u);
199 BOOST_CHECK_CLOSE_FRACTION(std::get<double>(result), 4.1,
tolerance);
BOOST_AUTO_TEST_CASE |
( |
map_vector |
| ) |
|
Definition at line 202 of file aggregate_t.cc.
205 using key_type =
typename mv_t::key_type;
207 primes.
insert({key_type{2},
"two"});
208 primes.insert({key_type{3},
"three"});
209 primes.insert({key_type{5},
"five"});
212 more_nums.insert({key_type{7},
"seven"});
213 more_nums.insert({key_type{11},
"eleven"});
214 more_nums.insert({key_type{13},
"thirteen"});
218 r.
put<mv_t>(more_nums);
221 ref.insert({key_type{2},
"two"});
222 ref.insert({key_type{3},
"three"});
223 ref.insert({key_type{5},
"five"});
224 ref.insert({key_type{7},
"seven"});
225 ref.insert({key_type{11},
"eleven"});
226 ref.insert({key_type{13},
"thirteen"});
228 BOOST_TEST(r.
get<mv_t>() == ref, boost::test_tools::per_element{});
std::pair< iterator, bool > insert(value_type const &x)
BOOST_AUTO_TEST_CASE |
( |
string1 |
| ) |
|
Definition at line 231 of file aggregate_t.cc.
236 BOOST_REQUIRE_EXCEPTION(
238 return e.categoryCode() == art::errors::ProductCannotBeAggregated;
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
BOOST_AUTO_TEST_CASE |
( |
string2 |
| ) |
|
ostream& std::operator<< |
( |
ostream & |
os, |
|
|
pair< string, unsigned > const & |
p |
|
) |
| |
Definition at line 55 of file aggregate_t.cc.
57 os <<
'[' <<
p.first <<
',' <<
p.second <<
']';