Commit f46b9dc3 authored by Kenneth Leiter's avatar Kenneth Leiter
Browse files

ENH: When array is uninitialized return dimensions as [0] and "0"

rather than empty array or empty string.

Add logic in TestXdmfArray to test this.
parent 08bfa4eb
......@@ -444,10 +444,8 @@ XdmfArray::getDimensions() const
if(mHaveArray) {
if(mDimensions.size() == 0) {
const unsigned int size = boost::apply_visitor(Size(), mArray);
if(size > 0) {
std::vector<unsigned int> toReturn(1, size);
return toReturn;
}
std::vector<unsigned int> toReturn(1, size);
return toReturn;
}
return mDimensions;
}
......@@ -457,7 +455,7 @@ XdmfArray::getDimensions() const
else if(mHeavyDataController) {
return mHeavyDataController->getDimensions();
}
return mDimensions;
return std::vector<unsigned int>(1, 0);
}
std::string
......
......@@ -18,6 +18,10 @@ int main(int, char *)
assert(array->getArrayType() == XdmfArrayType::Uninitialized());
assert(array->getValuesString() == "");
assert(array->getValuesInternal() == NULL);
std::vector<unsigned int> dimensions = array->getDimensions();
assert(dimensions.size() == 1);
assert(dimensions[0] == 0);
assert(array->getDimensionsString().compare("0 ") == 0);
array->insert(0, &values[0], 4, 1, 1);
assert(array->getSize() == 4);
assert(array->getArrayType() == XdmfArrayType::Int32());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment