195 using Container_t = Cont;
197 using Data_t = Literal_t;
199 constexpr Literal_t defaultValue { 42 };
203 auto const data = makeTestData<Cont>();
207 std::array<std::size_t, 12U>
const mapping1 = {{
208 4U, 3U, 2U, 1U, 0U, InvalidIndex,
209 9U, 8U, 7U, 6U, 5U, InvalidIndex,
212 std::array<Literal_t, 12U>
const expectedMappedData1 = {{
213 -4, -3, -2, -1, 0, defaultValue,
214 -9, -8, -7, -6, -5, defaultValue
218 std::ref(data), mapping1, expectedMappedData1.size(),
227 typename decltype(mappedData1)::const_iterator::reference,
232 BOOST_TEST(mappedData1.size() == expectedMappedData1.size());
233 BOOST_TEST(mappedData1.minimal_size() == expectedMappedData1.size());
235 BOOST_TEST(mappedData1.front() == expectedMappedData1.front());
236 BOOST_TEST(mappedData1.back() == expectedMappedData1.back());
239 auto const beginIterator = mappedData1.begin();
240 auto const secondIterator = beginIterator + 1;
241 auto mappedIterator = beginIterator;
242 for (
auto&& mappedValue: mappedData1) {
243 BOOST_TEST_CHECKPOINT(
"mapped item: " << i);
245 std::size_t
const& expectedMappedIndex = mapping1[i];
246 Data_t
const expectedValue = expectedMappedData1[i];
247 Data_t
const& expectedRef = (expectedMappedIndex == InvalidIndex)
248 ? mappedData1.defaultValue()
249 : data[expectedMappedIndex]
251 BOOST_TEST(expectedRef == expectedValue);
253 decltype(
auto) mappedDataRef = mappedData1[i];
254 static_assert(
std::is_reference_v<decltype(mappedDataRef)>);
256 BOOST_TEST(mappedData1.map_index(i) == expectedMappedIndex);
257 BOOST_TEST(mappedValue == expectedValue);
258 BOOST_TEST(mappedDataRef == expectedValue);
259 BOOST_TEST(mappedData1.at(i) == expectedValue);
260 BOOST_TEST(beginIterator[i] == expectedValue);
261 BOOST_TEST(*(beginIterator + i) == expectedValue);
262 BOOST_TEST(*mappedIterator == expectedValue);
264 BOOST_TEST(secondIterator[i-1] == expectedValue);
265 BOOST_TEST(*(secondIterator + i - 1) == expectedValue);
266 BOOST_TEST( (mappedIterator != beginIterator));
267 BOOST_TEST(!(mappedIterator == beginIterator));
268 BOOST_TEST( (mappedIterator > beginIterator));
269 BOOST_TEST( (mappedIterator >= beginIterator));
270 BOOST_TEST(!(mappedIterator < beginIterator));
271 BOOST_TEST(!(mappedIterator <= beginIterator));
272 BOOST_TEST( (beginIterator != mappedIterator));
273 BOOST_TEST(!(beginIterator == mappedIterator));
274 BOOST_TEST(!(beginIterator > mappedIterator));
275 BOOST_TEST(!(beginIterator >= mappedIterator));
276 BOOST_TEST( (beginIterator < mappedIterator));
277 BOOST_TEST( (beginIterator <= mappedIterator));
280 BOOST_TEST(!(mappedIterator != beginIterator));
281 BOOST_TEST( (mappedIterator == beginIterator));
282 BOOST_TEST(!(mappedIterator > beginIterator));
283 BOOST_TEST( (mappedIterator >= beginIterator));
284 BOOST_TEST(!(mappedIterator < beginIterator));
285 BOOST_TEST( (mappedIterator <= beginIterator));
286 BOOST_TEST(!(beginIterator != mappedIterator));
287 BOOST_TEST( (beginIterator == mappedIterator));
288 BOOST_TEST(!(beginIterator > mappedIterator));
289 BOOST_TEST( (beginIterator >= mappedIterator));
290 BOOST_TEST(!(beginIterator < mappedIterator));
291 BOOST_TEST( (beginIterator <= mappedIterator));
297 BOOST_TEST(&mappedDataRef == &expectedRef);
301 if (mapping1[i] != InvalidIndex)
302 BOOST_TEST(mappedData2[i] == mappedData1[i]);
303 BOOST_TEST(&mappedData2.map_index(i) == &expectedMappedIndex);
308 BOOST_TEST(i == expectedMappedData1.size());
311 while (i < expectedMappedData1.size() + 3U) {
312 BOOST_TEST_CHECKPOINT(
"mapped item: " << i <<
" (overflow)");
313 BOOST_CHECK_THROW(mappedData1.at(i), std::out_of_range);
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
then if[["$THISISATEST"==1]]
A meta-container providing transparent mapping on top of another.
static constexpr T invalidIndex()