24 #include "../MultiArrayTest.h"
25 #include "../TestMultiArray.h"
31 namespace astrotypes {
59 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size);
68 ASSERT_EQ(std::distance(it, end), (std::size_t)size);
70 std::for_each(it, end, [&](
int const& val)
75 ASSERT_EQ(n, (
unsigned)size);
86 ASSERT_EQ(&*slice0.begin(), &*ma.
begin());
87 int* end0=&*ma.
begin() + (size_b * (size_a - 1) +1 );
88 ASSERT_EQ(&*slice0.end(), end0) <<
"delta=" << end0 - &*slice0.end();
90 ASSERT_EQ(slice0.dimension<
DimensionA>(), size_a);
92 auto it = slice0.cbegin();
93 auto end = slice0.cend();
94 ASSERT_EQ(std::distance(it, end), (std::size_t)size_a);
96 std::for_each(it, end, [&](
int const& val)
99 n += (std::size_t)size_b;
101 ASSERT_EQ(n, (
unsigned)size_b * size_a);
105 ASSERT_EQ(&*slice1.begin(), (&*ma.
begin()) + 1);
106 int* end1=&*slice1.begin() + (size_b * (size_a - 1) +1 );
107 ASSERT_EQ(&*slice1.end(), end1) <<
"delta=" << end1 - &*slice1.end();
117 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
118 auto it = slice.cbegin();
119 auto end = slice.cend();
120 ASSERT_EQ(std::distance(it, end), (std::size_t)size_b);
121 unsigned n=(unsigned)size_b;
122 std::for_each(it, end, [&](
int const& val)
127 ASSERT_EQ(n-(
unsigned)size_b, (
unsigned)size_b);
136 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
137 auto it = slice.cbegin();
138 auto end = slice.cend();
139 ASSERT_EQ(std::distance(it, end), (std::size_t)size_b);
140 unsigned n=(unsigned)size_b;
141 std::for_each(it, end, [&](
int const& val)
146 ASSERT_EQ(n-(
unsigned)size_b, (
unsigned)size_b);
200 ASSERT_EQ(ba[j][i], ab[i][j]) <<
" i=" << i <<
" j=" << j <<
" " << &ba[j][i];
224 auto slice = ma[index];
227 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
228 ASSERT_EQ(slice.dimension<
DimensionC>(), size_c);
240 auto slice = ma[index];
243 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
244 ASSERT_EQ(slice.dimension<
DimensionC>(), size_c);
259 SCOPED_TRACE(index_2);
261 ASSERT_EQ(static_cast<std::size_t>(slice.dimension<
DimensionA>()), (index_2 - index) + 1 );
262 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
263 ASSERT_EQ(slice.dimension<
DimensionC>(), size_c);
279 ASSERT_EQ(static_cast<std::size_t>(slice.dimension<
DimensionA>()), (index_2 - index) + 1 );
280 ASSERT_EQ(slice.dimension<
DimensionB>(), size_b);
281 ASSERT_EQ(slice.dimension<
DimensionC>(), size_c);
292 std::vector<unsigned> data(size_a * size_b * size_c);
294 std::generate(data.begin(), data.end(), [&]() {
return val++; } );
297 std::copy(data.begin(), data.end(), ma.begin());
307 std::vector<unsigned> dst;
308 dst.reserve(size_a * size_b * size_c);
309 std::copy(ma.begin(), ma.end(), std::back_inserter(dst));
310 ASSERT_EQ(data.size(), dst.size());
311 ASSERT_EQ(data, dst);
315 std::copy(ma.cbegin(), ma.cend(), std::back_inserter(dst));
316 ASSERT_EQ(data, dst);
328 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a);
338 ma.resize(size_a, 99);
340 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a);
342 ASSERT_EQ(ma[i], 99U);
356 ASSERT_EQ(ma[i][j], 199U);
374 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a * size_b * size_c);
381 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a * size_b * size_c);
388 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a * size_b * size_c);
400 ma.resize(size_a, size_b);
401 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a * size_b * size_c);
405 ma.resize(size_b, size_c);
406 ASSERT_EQ(std::distance(ma.
begin(), ma.
end()), size_a * size_b * size_c);
416 ASSERT_EQ(ma.
data_size(), size_a * size_b * size_c);
430 ASSERT_EQ(ma_1, ma_2);
434 ASSERT_FALSE(ma_1 == ma_3);
438 ASSERT_FALSE(ma_1 == ma_2);
446 typedef MultiArray<std::allocator<unsigned>, unsigned, TestMultiArrayMixin,
DimensionA,
DimensionB> TestType2d;
455 typedef MultiArray<std::allocator<unsigned>, unsigned, TestMultiArrayMixin,
DimensionA,
DimensionB> TestType2d;
const_iterator cend() const
A tagged dimensionIndex variable.
Defines a contiguous range over dimension in index.
std::size_t data_size() const
the total size of data in all dimensions
TEST_F(MultiArrayTest, test_single_dimension_size)
const_iterator cbegin() const
An instantiation of the MutliArray template for unit tests.
return true if the Dimensions provided match exactly those of the structure T (including order) ...
A compile time dimesion tagging of size_t.
iterator begin()
iterators acting over he entire data structure
return true if the Dimension is represented in the structure
template classes to specify multiple dimension arrays with explicit dimension types ...
std::enable_if< std::is_same< Dim, Dimensions... >::value, DimensionSize< Dimensions... > >::type dimension() const