Unit test for larcorealg/CoreUtils/operations.h
.
More...
#include <boost/test/unit_test.hpp>
#include "larcorealg/CoreUtils/operations.h"
#include "larcorealg/CoreUtils/zip.h"
#include "larcorealg/CoreUtils/UncopiableAndUnmovableClass.h"
#include <vector>
#include <algorithm>
#include <memory>
#include <numeric>
Go to the source code of this file.
Unit test for larcorealg/CoreUtils/operations.h
.
- Author
- Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
- Date
- June 5, 2019
- See Also
larcorealg/CoreUtils/operations.h
Definition in file operations_test.cc.
#define BOOST_TEST_MODULE ( operations_test ) |
BOOST_AUTO_TEST_CASE |
( |
takeAddress_testcase |
| ) |
|
Definition at line 296 of file operations_test.cc.
void test_takeAddress_whyBother()
void test_AddressTaker_documentation()
void test_takeAddress_documentation()
BOOST_AUTO_TEST_CASE |
( |
dereference_testcase |
| ) |
|
Definition at line 307 of file operations_test.cc.
void test_dereference_documentation()
void test_Dereferencer_documentation()
void test_dereference_unique_ptr()
void test_dereference_C_ptr()
void test_dereference_uncopiable()
void test_AddressTaker_documentation |
( |
| ) |
|
Definition at line 28 of file operations_test.cc.
30 std::vector<int> data(10U);
31 std::iota(data.begin(), data.end(), 0U);
42 std::vector<int*> ptrs(data.size());
48 BOOST_TEST(ptrs.size() == data.size());
52 BOOST_TEST(*ptr ==
value);
53 BOOST_TEST(ptr == &
value);
Functor returning the address in memory of the operand.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_dereference_C_ptr |
( |
| ) |
|
Definition at line 225 of file operations_test.cc.
227 std::vector<int> data(10U);
228 std::iota(data.begin(), data.end(), 0U);
230 std::vector<int const*> dataPtrs;
231 std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtrs),
234 std::vector<int> dataAgain;
236 dataPtrs.cbegin(), dataPtrs.cend(),
237 std::back_inserter(dataAgain),
241 BOOST_TEST(dataAgain.size() == data.size());
244 BOOST_TEST(valueAgain ==
value);
245 BOOST_TEST(&valueAgain != &
value);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
decltype(auto) dereference()
Returns a functor that returns *ptr of its argument ptr.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_dereference_documentation |
( |
| ) |
|
Definition at line 191 of file operations_test.cc.
193 std::vector<int> data(10U);
194 std::iota(data.begin(), data.end(), 0U);
196 std::vector<int*> ptrs(data.size());
208 std::vector<int>
values(ptrs.size());
213 BOOST_TEST(
values.size() == data.size());
216 BOOST_TEST(
value == orig);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
decltype(auto) dereference()
Returns a functor that returns *ptr of its argument ptr.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_dereference_uncopiable |
( |
| ) |
|
Definition at line 281 of file operations_test.cc.
288 ToughInt
const* pValue = &
value;
An empty class that can't be copied nor moved.
decltype(auto) dereference()
Returns a functor that returns *ptr of its argument ptr.
void test_dereference_unique_ptr |
( |
| ) |
|
Definition at line 253 of file operations_test.cc.
255 std::vector<int> data(10U);
256 std::iota(data.begin(), data.end(), 0U);
258 std::vector<std::unique_ptr<int>> dataPtrs;
259 dataPtrs.reserve(data.size());
260 for (
auto&&
value: data) dataPtrs.push_back(std::make_unique<int>(
value));
262 std::vector<int> dataAgain;
264 dataPtrs.cbegin(), dataPtrs.cend(),
265 std::back_inserter(dataAgain),
269 BOOST_TEST(dataAgain.size() == data.size());
272 BOOST_TEST(valueAgain ==
value);
273 BOOST_TEST(&valueAgain != &
value);
decltype(auto) dereference()
Returns a functor that returns *ptr of its argument ptr.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_Dereferencer_documentation |
( |
| ) |
|
Definition at line 158 of file operations_test.cc.
160 std::vector<int> data(10U);
161 std::iota(data.begin(), data.end(), 0U);
163 std::vector<int*> ptrs(data.size());
175 std::vector<int>
values(ptrs.size());
180 BOOST_TEST(
values.size() == data.size());
183 BOOST_TEST(
value == orig);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Functor dereferencing the operand.
void test_takeAddress |
( |
| ) |
|
Definition at line 94 of file operations_test.cc.
96 std::vector<int> data(10U);
97 std::iota(data.begin(), data.end(), 0U);
99 std::vector<int const*> dataPtr;
100 std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),
106 BOOST_TEST(*ptr ==
value);
107 BOOST_TEST(ptr == &
value);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_takeAddress_documentation |
( |
| ) |
|
Definition at line 62 of file operations_test.cc.
64 std::vector<int> data(10U);
65 std::iota(data.begin(), data.end(), 0U);
75 std::vector<int*> ptrs(data.size());
80 BOOST_TEST(ptrs.size() == data.size());
84 BOOST_TEST(*ptr ==
value);
85 BOOST_TEST(ptr == &
value);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
void test_takeAddress_whyBother |
( |
| ) |
|
Definition at line 115 of file operations_test.cc.
117 std::vector<int> data(10U);
118 std::iota(data.begin(), data.end(), 0U);
120 std::vector<int const*> dataPtr;
124 using addressof_t =
int const*(*)(
int const&);
126 std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),
127 ((addressof_t) &std::addressof));
132 BOOST_TEST(*ptr ==
value);
133 BOOST_TEST(ptr == &
value);
141 auto takeAddress = [](
auto&& ref){
return std::addressof(ref); };
143 std::transform(data.cbegin(), data.cend(), std::back_inserter(dataPtr),
149 BOOST_TEST(*ptr ==
value);
150 BOOST_TEST(ptr == &
value);
decltype(auto) takeAddress()
Returns a functor that returns the address of its argument.
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.