#include "larcorealg/CoreUtils/values.h"
#include <boost/test/unit_test.hpp>
#include <numeric>
#include <vector>
#include <map>
#include <utility>
#include <cstddef>
Go to the source code of this file.
#define BOOST_TEST_MODULE ( values_test ) |
BOOST_AUTO_TEST_CASE |
( |
values_testcase |
| ) |
|
Definition at line 191 of file values_test.cc.
195 test_values_map<std::map>();
196 test_const_values_map<std::map>();
void test_values_documentation()
void test_const_values |
( |
| ) |
|
Definition at line 74 of file values_test.cc.
77 constexpr std::size_t
N = 7U;
79 std::vector<float>
data(N);
80 std::iota(
data.begin(),
data.end(), 0.0F);
86 static_assert(std::is_same_v<
88 std::add_lvalue_reference_t<std::vector<float>
const>
98 static_assert(std::is_const_v<std::remove_reference_t<decltype(
value)>>);
100 BOOST_TEST(std::addressof(
value) == std::addressof(
data[i]));
103 BOOST_TEST(i ==
data.size());
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
template<template< typename Key, typename Value, typename...Args > typename Map>
void test_const_values_map |
( |
| ) |
|
Definition at line 135 of file values_test.cc.
138 constexpr std::size_t
N = 7U;
139 constexpr
double factor = 5.0;
141 std::vector<int>
keys(N);
142 std::iota(
keys.begin(),
keys.end(), 0U);
143 Map<int, float>
data;
148 static_assert(std::is_same_v<decltype(
value),
float const&>);
149 BOOST_TEST(
value == data[i]);
150 BOOST_TEST(std::addressof(
value) == std::addressof(data[i]));
153 BOOST_TEST(i == data.size());
decltype(auto) const_values(Coll &&coll)
Range-for loop helper iterating across the constant values of the specified collection.
Definition at line 26 of file values_test.cc.
29 constexpr std::size_t
N = 7U;
31 std::vector<float>
data(N);
32 std::iota(
data.begin(),
data.end(), 0.0F);
38 static_assert(std::is_same_v<
40 std::add_lvalue_reference_t<std::vector<float>>
52 BOOST_TEST(std::addressof(
value) == std::addressof(
data[i]));
55 BOOST_TEST(i ==
data.size());
65 BOOST_TEST(std::addressof(
value) == std::addressof(
data[i]));
68 BOOST_TEST(i ==
data.size());
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
void test_values_documentation |
( |
| ) |
|
Definition at line 159 of file values_test.cc.
173 std::map<int, float>
data { { 1, 4.0F }, { 3, 12.0F }, { 2, 8.0F } };
174 std::vector<float>
values;
177 values.push_back(
value);
180 BOOST_TEST(values.size() == 3U);
181 BOOST_TEST(values[0] == 4.0F);
182 BOOST_TEST(values[1] == 8.0F);
183 BOOST_TEST(values[2] == 12.0F);
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
template<template< typename Key, typename Value, typename...Args > typename Map>
Definition at line 110 of file values_test.cc.
113 constexpr std::size_t
N = 7U;
114 constexpr
double factor = 5.0;
116 std::vector<int>
keys(N);
117 std::iota(
keys.begin(),
keys.end(), 0U);
118 Map<int, float>
data;
123 static_assert(std::is_same_v<decltype(
value),
float&>);
124 BOOST_TEST(
value == data[i]);
125 BOOST_TEST(std::addressof(
value) == std::addressof(data[i]));
128 BOOST_TEST(i == data.size());
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.