Skip to content

Commit

Permalink
Fixed bug with buffer_vector::push_back.
Browse files Browse the repository at this point in the history
Signed-off-by: vng <[email protected]>
  • Loading branch information
vng committed Apr 23, 2021
1 parent 58ae15d commit 5613477
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions base/base_tests/buffer_vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ namespace
}
}

UNIT_TEST(BufferVector_PushBack_And_Realloc)
{
using ElementT = std::vector<int>;
ElementT element({1, 2, 3});

buffer_vector<ElementT, 2> v;
v.append(2, element);

v.push_back(v[0]);
TEST_EQUAL(v.size(), 3, ());
TEST_EQUAL(v[2], element, ());
}

UNIT_TEST(BufferVectorBounds)
{
buffer_vector<size_t, 2> v;
Expand Down Expand Up @@ -280,11 +293,14 @@ struct CopyCtorChecker

CopyCtorChecker() = default;
explicit CopyCtorChecker(char const * s) : m_s(s) {}

CopyCtorChecker(CopyCtorChecker const & rhs)
{
TEST(rhs.m_s.empty(), ("Copy ctor is called only in resize with default element"));
}
CopyCtorChecker(CopyCtorChecker && rhs) = default;

CopyCtorChecker & operator=(CopyCtorChecker &&) = default;
CopyCtorChecker & operator=(CopyCtorChecker const &)
{
TEST(false, ("Assigment operator should not be called"));
Expand Down
2 changes: 1 addition & 1 deletion base/buffer_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ template <class T, size_t N> class buffer_vector
Swap(m_static[i], rhs.m_static[i]);
}

void push_back(T const & t)
void push_back(T t)
{
if (IsDynamic())
{
Expand Down
2 changes: 1 addition & 1 deletion routing/index_graph_starter_joints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ bool IndexGraphStarterJoints<Graph>::FillEdgesAndParentsWeights(
if (edges.size() != prevSize)
{
CHECK_LESS(i, parentWeights.size(), ());
parentWeights.emplace_back(parentWeights[i]);
parentWeights.push_back(parentWeights[i]);
}
}
}
Expand Down

0 comments on commit 5613477

Please sign in to comment.