forked from organicmaps/organicmaps
One more insert method for buffer_vector.
This commit is contained in:
parent
0d03b829ee
commit
a93073c2b4
2 changed files with 35 additions and 0 deletions
|
@ -164,6 +164,36 @@ UNIT_TEST(BufferVectorInsert)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(BufferVectorInsertSingleValue)
|
||||
{
|
||||
buffer_vector<char, 3> v;
|
||||
v.insert(v.end(), 'x');
|
||||
TEST_EQUAL(v.size(), 1, ());
|
||||
TEST_EQUAL(v[0], 'x', ());
|
||||
|
||||
v.insert(v.begin(), 'y');
|
||||
TEST_EQUAL(v.size(), 2, ());
|
||||
TEST_EQUAL(v[0], 'y', ());
|
||||
TEST_EQUAL(v[1], 'x', ());
|
||||
|
||||
v.insert(v.begin() + 1, 'z');
|
||||
TEST_EQUAL(v.size(), 3, ());
|
||||
TEST_EQUAL(v[0], 'y', ());
|
||||
TEST_EQUAL(v[1], 'z', ());
|
||||
TEST_EQUAL(v[2], 'x', ());
|
||||
// Switch to dynamic.
|
||||
v.insert(v.begin() + 1, 'q');
|
||||
TEST_EQUAL(v.size(), 4, ());
|
||||
TEST_EQUAL(v[0], 'y', ());
|
||||
TEST_EQUAL(v[1], 'q', ());
|
||||
TEST_EQUAL(v[2], 'z', ());
|
||||
TEST_EQUAL(v[3], 'x', ());
|
||||
|
||||
v.insert(v.end() - 1, 'c');
|
||||
TEST_EQUAL(v[3], 'c', ());
|
||||
TEST_EQUAL(v[4], 'x', ());
|
||||
}
|
||||
|
||||
UNIT_TEST(BufferVectorAppend)
|
||||
{
|
||||
for (size_t initialLength = 0; initialLength < 20; ++initialLength)
|
||||
|
|
|
@ -368,6 +368,11 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
inline void insert(const_iterator where, value_type const & value)
|
||||
{
|
||||
insert(where, &value, &value + 1);
|
||||
}
|
||||
|
||||
private:
|
||||
void SwitchToDynamic()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue