diff options
author | Noel Grandin <noel@peralex.com> | 2012-07-13 15:13:47 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-17 15:28:09 +0200 |
commit | 194070ca6154fdc4a704f872463a084fdb922032 (patch) | |
tree | 9d7acadb6cfb704a94ab9f8ea571d864fcbe381b /o3tl/qa | |
parent | 0f57086b221eb1e7d3d9d7cdb6f3cdcb50f1edda (diff) |
Add erase(size_t) method to o3tl::sorted_vector
I can't add a regular erase(iterator) method because we only hand
out const_iterator's
Change-Id: Ia3bdecb0f909d0712138c7ee48da268951e2733b
Diffstat (limited to 'o3tl/qa')
-rw-r--r-- | o3tl/qa/test-sorted_vector.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx index 16dc1dd36173..5641ad2cd177 100644 --- a/o3tl/qa/test-sorted_vector.cxx +++ b/o3tl/qa/test-sorted_vector.cxx @@ -70,6 +70,36 @@ public: aVec.DeleteAndDestroyAll(); } + void testErase() + { + o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec; + SwContent *p1 = new SwContent(1); + SwContent *p2 = new SwContent(2); + SwContent *p3 = new SwContent(3); + SwContent *p4 = new SwContent(4); + + aVec.insert(p1); + aVec.insert(p2); + aVec.insert(p3); + + CPPUNIT_ASSERT( aVec.erase(p1) == 1 ); + CPPUNIT_ASSERT( aVec.size() == 2 ); + + aVec.erase(1); + CPPUNIT_ASSERT( aVec.size() == 1 ); + + CPPUNIT_ASSERT( aVec.erase(p4) == 0 ); + + aVec.clear(); + CPPUNIT_ASSERT( aVec.size() == 0 ); + + aVec.insert(p1); + aVec.insert(p2); + aVec.insert(p3); + aVec.DeleteAndDestroyAll(); + CPPUNIT_ASSERT( aVec.size() == 0 ); + } + void testInsertRange() { o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec1; @@ -109,6 +139,7 @@ public: CPPUNIT_TEST_SUITE(sorted_vector_test); CPPUNIT_TEST(testBasics); + CPPUNIT_TEST(testErase); CPPUNIT_TEST(testInsertRange); CPPUNIT_TEST(testLowerBound); CPPUNIT_TEST_SUITE_END(); |