Macros | Functions
return_value_defaults_t.cc File Reference
#include "boost/test/unit_test.hpp"
#include "fhiclcpp/types/Atom.h"
#include "fhiclcpp/types/Sequence.h"
#include "fhiclcpp/types/Tuple.h"
#include <string>
#include <vector>

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   (return value defaults)
 

Functions

 BOOST_AUTO_TEST_CASE (one_atom_t)
 
 BOOST_AUTO_TEST_CASE (one_sequence_t)
 
 BOOST_AUTO_TEST_CASE (one_sequence_2_t)
 
 BOOST_AUTO_TEST_CASE (one_tuple_t)
 
 BOOST_AUTO_TEST_CASE (seq_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (bounded_seq_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (tuple_in_tuple_t)
 
 BOOST_AUTO_TEST_CASE (tuple_in_seq_t)
 
 BOOST_AUTO_TEST_CASE (tuple_in_seq_2_t)
 
 BOOST_AUTO_TEST_CASE (seq_in_seq_t)
 
 BOOST_AUTO_TEST_CASE (seq_2_in_seq_t)
 
 BOOST_AUTO_TEST_CASE (seq_in_seq_2_t)
 
 BOOST_AUTO_TEST_CASE (seq_2_in_seq_2_t)
 

Macro Definition Documentation

#define BOOST_TEST_MODULE   (return value defaults)

Definition at line 9 of file return_value_defaults_t.cc.

Function Documentation

BOOST_AUTO_TEST_CASE ( one_atom_t  )

Definition at line 27 of file return_value_defaults_t.cc.

28 {
29  Atom<int> test{Name("atom"), 4};
30  BOOST_TEST(test() == 4);
31 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( one_sequence_t  )

Definition at line 34 of file return_value_defaults_t.cc.

35 {
36  auto ref = {1, 2, 4};
37  Sequence<int> test{Name("sequence"), ref};
38  BOOST_TEST(test() == ref, boost::test_tools::per_element{});
39  std::size_t i{};
40  for (auto const& elem : ref)
41  BOOST_TEST(elem == test(i++));
42 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( one_sequence_2_t  )

Definition at line 45 of file return_value_defaults_t.cc.

46 {
47  auto ref = {5, 7};
48  Sequence<int, 2> test{Name("sequence"), ref};
49  BOOST_TEST(test() == ref, boost::test_tools::per_element{});
50 
51  std::size_t i{};
52  for (auto const& elem : ref)
53  BOOST_TEST(elem == test(i++));
54 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( one_tuple_t  )

Definition at line 57 of file return_value_defaults_t.cc.

58 {
59  Tuple<int, double, bool> test{Name("tuple"), {4, 1.5, false}};
60  BOOST_TEST(test.get<0>() == 4);
61  BOOST_TEST(test.get<1>() == 1.5);
62  BOOST_TEST(test.get<2>() == false);
63 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( seq_in_tuple_t  )

Definition at line 66 of file return_value_defaults_t.cc.

67 {
68  auto ref = {1, 3, 5};
69  Tuple<Sequence<int>, double, bool> test{Name("tuple"), {ref, 4.6, true}};
70  BOOST_TEST(test.get<0>() == ref, boost::test_tools::per_element{});
71  BOOST_TEST(test.get<1>() == 4.6);
72  BOOST_TEST(test.get<2>() == true);
73 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( bounded_seq_in_tuple_t  )

Definition at line 76 of file return_value_defaults_t.cc.

77 {
78  auto ref = {9, 15};
79  Tuple<Sequence<int, 2>, double, bool> test{Name("tuple"), {ref, 0.2, false}};
80  BOOST_TEST(test.get<0>() == ref, boost::test_tools::per_element{});
81  BOOST_TEST(test.get<1>() == 0.2);
82  BOOST_TEST(test.get<2>() == false);
83 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( tuple_in_tuple_t  )

Definition at line 86 of file return_value_defaults_t.cc.

87 {
88  Tuple<Tuple<int, float>, double, bool> test{Name("tuple"),
89  {{4, 3.7f}, 8.1, true}};
90  auto const tuple0 = test.get<0>();
91  BOOST_TEST(std::get<0>(tuple0) == 4);
92  BOOST_TEST(std::get<1>(tuple0) == 3.7f);
93  BOOST_TEST(test.get<1>() == 8.1);
94  BOOST_TEST(test.get<2>() == true);
95 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( tuple_in_seq_t  )

Definition at line 98 of file return_value_defaults_t.cc.

99 {
100  std::vector<std::tuple<int, float>> ref_vec{std::make_tuple(2, 5.4f),
101  std::make_tuple(4, 104.5f),
102  std::make_tuple(8, 15.3f)};
103  Sequence<Tuple<int, float>> test{Name("seqtuple"),
104  {{2, 5.4f}, {4, 104.5f}, {8, 15.3f}}};
105  std::size_t i{};
106  for (auto const& elem : test()) {
107  BOOST_TEST(std::get<0>(elem) == std::get<0>(ref_vec.at(i)));
108  BOOST_TEST(std::get<1>(elem) == std::get<1>(ref_vec.at(i++)));
109  }
110 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( tuple_in_seq_2_t  )

Definition at line 113 of file return_value_defaults_t.cc.

114 {
115  std::array<std::tuple<int, float>, 2> ref_vec{
116  {std::make_tuple(1, 2.3f), std::make_tuple(9, 3.2f)}};
117 
118  Sequence<Tuple<int, float>, 2> test{Name("seqtuple"), {{1, 2.3f}, {9, 3.2f}}};
119  std::size_t i{};
120  for (auto const& elem : test()) {
121  BOOST_TEST(std::get<0>(elem) == std::get<0>(ref_vec.at(i)));
122  BOOST_TEST(std::get<1>(elem) == std::get<1>(ref_vec.at(i++)));
123  }
124 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( seq_in_seq_t  )

Definition at line 127 of file return_value_defaults_t.cc.

128 {
129  auto ref_vec = std::vector<std::vector<int>>{{1, 5, 7}, {2}};
130  Sequence<Sequence<int>> test{Name("seqseq"), {{1, 5, 7}, {2}}};
131  std::size_t i{};
132  for (auto const& val : test()) {
133  auto ref = ref_vec.at(i++);
134  BOOST_TEST(val == ref);
135  }
136 
137  i = 0ul;
138  for (auto const& ref : ref_vec) {
139  auto val = test(i++);
140  BOOST_TEST(val == ref);
141  }
142 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( seq_2_in_seq_t  )

Definition at line 145 of file return_value_defaults_t.cc.

146 {
147  auto ref_vec = std::vector<std::array<int, 2>>{{{1, 2}}};
148  Sequence<Sequence<int, 2>> test{Name("seqseq"), {{1, 2}}};
149  std::size_t i{};
150  for (auto const& val : test()) {
151  auto ref = ref_vec.at(i++);
152  BOOST_TEST(val == ref);
153  }
154 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( seq_in_seq_2_t  )

Definition at line 157 of file return_value_defaults_t.cc.

158 {
159  std::array<std::vector<int>, 2> ref_vec{
160  {std::vector<int>{4}, std::vector<int>{{1, 4, 9, 1}}}};
161 
162  Sequence<Sequence<int>, 2> test{Name("seqseq"), {{4}, {1, 4, 9, 1}}};
163  std::size_t i{};
164  for (auto const& val : test()) {
165  auto ref = ref_vec.at(i++);
166  BOOST_TEST(val == ref);
167  }
168 }
ChannelGroupService::Name Name
BOOST_AUTO_TEST_CASE ( seq_2_in_seq_2_t  )

Definition at line 171 of file return_value_defaults_t.cc.

172 {
173  std::array<std::array<int, 2>, 2> ref_vec{
174  {std::array<int, 2>{{6, 7}}, std::array<int, 2>{{2, 1}}}};
175 
176  Sequence<Sequence<int, 2>, 2> test{Name("seqseq"), {{6, 7}, {2, 1}}};
177  std::size_t i{};
178  for (auto const& val : test()) {
179  auto ref = ref_vec.at(i++);
180  BOOST_TEST(val == ref);
181  }
182 }
ChannelGroupService::Name Name