summaryrefslogtreecommitdiff
path: root/o3tl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-05-13 20:50:57 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-05-13 15:28:48 +0200
commit72ce1de3e3c70fa94b0ed14541d751dd5654b6b0 (patch)
tree2db4ac02c9209b3af31922d93e57cf143e5bb5f8 /o3tl
parent7e6dac4edce063a766497ecb498e293bf4e16e66 (diff)
o3tl: add some comments to sorted_vector test
Change-Id: Iebedbb5afb45a92e52a8a390b9b7f6daae2337eb Reviewed-on: https://gerrit.libreoffice.org/54192 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'o3tl')
-rw-r--r--o3tl/qa/test-sorted_vector.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx
index 713cb185fa48..2a1f87d93dc8 100644
--- a/o3tl/qa/test-sorted_vector.cxx
+++ b/o3tl/qa/test-sorted_vector.cxx
@@ -37,26 +37,34 @@ public:
void testBasics()
{
o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec;
+
+ // create 4 test elements
std::unique_ptr<SwContent> p1( new SwContent(1) );
std::unique_ptr<SwContent> p2( new SwContent(2) );
SwContent *p3 = new SwContent(3);
std::unique_ptr<SwContent> p4( new SwContent(4) );
+ // insert p3, p1 -> not presernt -> second is true
CPPUNIT_ASSERT( aVec.insert(p3).second );
CPPUNIT_ASSERT( aVec.insert(p1.get()).second );
+ // insert p3 again -> already present -> second is false
CPPUNIT_ASSERT( !aVec.insert(p3).second );
+ // 2 element should be present
CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
+ // check the order -> should be p1, p3
+ // by index access
CPPUNIT_ASSERT_EQUAL( p1.get(), aVec[0] );
CPPUNIT_ASSERT_EQUAL( p3, aVec[1] );
-
+ // by begin, end
CPPUNIT_ASSERT_EQUAL( p1.get(), *aVec.begin() );
CPPUNIT_ASSERT_EQUAL( p3, *(aVec.end()-1) );
-
+ // by front, back
CPPUNIT_ASSERT_EQUAL( p1.get(), aVec.front() );
CPPUNIT_ASSERT_EQUAL( p3, aVec.back() );
+ // find elements
CPPUNIT_ASSERT( aVec.find(p1.get()) != aVec.end() );
CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(0), aVec.find(p1.get()) - aVec.begin() );
CPPUNIT_ASSERT( aVec.find(p3) != aVec.end() );