Allow for weak HDF5 array reading

This commit is contained in:
Guilhem Lavaux 2016-02-23 17:34:53 +01:00
parent 0174cdc8d6
commit 43d77feafe
2 changed files with 52 additions and 7 deletions

View file

@ -87,7 +87,7 @@ int main()
H5::Group g = f.createGroup("test_group");
array_type A(boost::extents[2][3]);
array_type B;
array_type B, Bprime(boost::extents[1][2]);
array3_type C(boost::extents[2][3][4]);
arrayc_type D, E;
array_mys_type F(boost::extents[10]), G;
@ -130,6 +130,7 @@ int main()
abort();
}
std::cout << "Testing C " << std::endl;
try
{
CosmoTool::hdf5_read_array(g, "test_data", C);
@ -138,6 +139,23 @@ int main()
}
catch (const CosmoTool::InvalidDimensions&)
{}
std::cout << "Testing Bprime " << std::endl;
try
{
CosmoTool::hdf5_read_array(g, "test_data", Bprime, false, true);
for (index i = 0; i != 1; i++)
for (index j = 0; j != 2; j++)
if (B[i][j] != Bprime[i][j]) {
std::cout << "Invalid array content in Bprime" << endl;
abort();
}
}
catch (const CosmoTool::InvalidDimensions&)
{
std::cout << "Bad! Dimensions should be accepted" << std::endl;
abort();
}
D.resize(boost::extents[2][3]);
D = A;