mirror of
https://github.com/boostorg/multi_array.git
synced 2025-05-11 21:33:52 +00:00
Added another test for resize preserving storage order.
[SVN r33238]
This commit is contained in:
parent
ecf3435632
commit
150fcf9a59
@ -69,5 +69,43 @@ int test_main(int,char*[]) {
|
||||
BOOST_CHECK(std::accumulate(defaultA.data(),
|
||||
defaultA.data()+(2*3*4),0) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// verify the preservation of storage order
|
||||
{
|
||||
int tiling_graph_storage_order[] = {2, 0, 1};
|
||||
bool tiling_graph_index_order[] = {true, true, true};
|
||||
|
||||
marray A(boost::extents[3][4][2],
|
||||
boost::general_storage_order<3>(tiling_graph_storage_order,
|
||||
tiling_graph_index_order));
|
||||
|
||||
|
||||
int value = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int k = 0; k < 2; k++) {
|
||||
*(A.data() + value) = value;
|
||||
++value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "Resize" to the same size
|
||||
A.resize(boost::extents[3][4][2]);
|
||||
|
||||
int check = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 4; j++) {
|
||||
for (int k = 0; k < 2; k++) {
|
||||
BOOST_CHECK(*(A.data() + check) == check);
|
||||
++check;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return boost::exit_success;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user