Skip to content
Snippets Groups Projects
Commit 3e6a89cc authored by Harald Scheirich's avatar Harald Scheirich
Browse files

BUG: VecDataArray was not doing the right thing on resize to 1

After default default contructing a vecdataarra a resize(1) would fail to set the size correctly
This fixes this and adds tests to this case
parent 14e9059b
No related branches found
No related tags found
No related merge requests found
......@@ -199,3 +199,10 @@ TEST(imstkDataArrayTest, ParameterCast)
EXPECT_DOUBLE_EQ(static_cast<double>(a[i]), (*actualB)[i]);
}
}
TEST(imstkDataArrayTest, ResizeToOne)
{
DataArray<int> a;
a.resize(1);
EXPECT_EQ(1, a.size());
}
\ No newline at end of file
......@@ -232,4 +232,11 @@ TEST(imstkVecDataArrayTest, ParameterCast)
{
EXPECT_TRUE(a[i].cast<double>().isApprox((*actualB)[i]));
}
}
TEST(imstkVecDataArrayTest, ResizeToOne)
{
VecDataArray<int, 2> a;
a.resize(1);
EXPECT_EQ(1, a.size());
}
\ No newline at end of file
......@@ -215,8 +215,15 @@ public:
inline void resize(const int size) override
{
// Can't resize a mapped vector
if (DataArray<T>::m_mapped || size == m_vecCapacity)
if (DataArray<T>::m_mapped)
{
return;
}
if (size == m_vecCapacity)
{
DataArray<T>::m_size = DataArray<T>::m_capacity;
m_vecSize = m_vecCapacity;
return;
}
......
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