Skip to content
Snippets Groups Projects
Commit 469aaca1 authored by Karsten Rink's avatar Karsten Rink
Browse files

Merge pull request #667 from TomFischer/SmallInterfaceChangePropertyVector

Small interface change class PropertyVector
parents 8eb52f10 ea2fd89e
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,11 @@ public: ...@@ -59,6 +59,11 @@ public:
return t; return t;
} }
std::size_t size() const
{
return std::vector<PROP_VAL_TYPE>::size() / _tuple_size;
}
protected: protected:
/// @brief The constructor taking meta information for the data. /// @brief The constructor taking meta information for the data.
/// @param property_name a string describing the property /// @param property_name a string describing the property
......
...@@ -461,3 +461,38 @@ TEST_F(MeshLibProperties, CopyConstructor) ...@@ -461,3 +461,38 @@ TEST_F(MeshLibProperties, CopyConstructor)
} }
} }
TEST_F(MeshLibProperties, AddDoublePropertiesTupleSize2)
{
ASSERT_TRUE(mesh != nullptr);
const std::size_t size(mesh_size*mesh_size*mesh_size);
std::string const prop_name("TestProperty");
boost::optional<MeshLib::PropertyVector<double> &> opt_pv(
mesh->getProperties().createNewPropertyVector<double>(prop_name,
MeshLib::MeshItemType::Cell, 2)
);
// PropertyVector should be created in a correct way
ASSERT_TRUE(!(!opt_pv));
MeshLib::PropertyVector<double> & pv(opt_pv.get());
ASSERT_EQ(0u, pv.getPropertyName().compare(prop_name));
ASSERT_EQ(MeshLib::MeshItemType::Cell, pv.getMeshItemType());
ASSERT_EQ(2u, pv.getTupleSize());
ASSERT_EQ(0u, pv.size());
// push some values (2 tuples) into the vector
for (std::size_t k(0); k<size; k++) {
pv.push_back(k);
pv.push_back(k);
}
// check the size, i.e., the number of tuples
ASSERT_EQ(size, pv.size());
// check the values
for (std::size_t k(0); k<size; k++) {
ASSERT_EQ(static_cast<double>(k), pv[2*k]);
ASSERT_EQ(static_cast<double>(k), pv[2*k+1]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment