From 72ce1de3e3c70fa94b0ed14541d751dd5654b6b0 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 13 May 2018 20:50:57 +0900 Subject: o3tl: add some comments to sorted_vector test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iebedbb5afb45a92e52a8a390b9b7f6daae2337eb Reviewed-on: https://gerrit.libreoffice.org/54192 Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- o3tl/qa/test-sorted_vector.cxx | 12 ++++++++++-- 1 file 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 > aVec; + + // create 4 test elements std::unique_ptr p1( new SwContent(1) ); std::unique_ptr p2( new SwContent(2) ); SwContent *p3 = new SwContent(3); std::unique_ptr 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(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(0), aVec.find(p1.get()) - aVec.begin() ); CPPUNIT_ASSERT( aVec.find(p3) != aVec.end() ); -- cgit