[Libreoffice-commits] core.git: svl/qa svl/source

Jochen Nitschke j.nitschke+logerrit at ok.de
Thu Sep 1 06:37:40 UTC 2016


 svl/qa/unit/items/test_itempool.cxx |   53 +++++++++++++++++-------------------
 svl/source/items/itempool.cxx       |    2 -
 2 files changed, 27 insertions(+), 28 deletions(-)

New commits:
commit d22525fcb03497a38ef5c9308ae7b50416ea9fb2
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date:   Thu Sep 1 01:27:42 2016 +0200

    avoid warning in PoolItemTest
    
    > warn:legacy.tools:19758:1:svl/source/inc/poolio.hxx:139:
    > Start-Which-Id must be greater 0
    
    adapt ID range in the test
    and leave usage comment in SfxItemPool ctor params
    
    Change-Id: I93150be8d3d1e330c6574b9f8d05b3b1ef2ffa43
    Reviewed-on: https://gerrit.libreoffice.org/28570
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx
index cc43694..bf52772 100644
--- a/svl/qa/unit/items/test_itempool.cxx
+++ b/svl/qa/unit/items/test_itempool.cxx
@@ -35,69 +35,68 @@ class PoolItemTest : public CppUnit::TestFixture
 void PoolItemTest::testPool()
 {
     SfxItemInfo aItems[] =
-        { { 0, true },
-          { 1, false /* not poolable */ },
-          { 2, false },
-          { 3, false /* not poolable */}
+        { { 1, true },
+          { 2, false /* not poolable */ },
+          { 3, false },
+          { 4, false /* not poolable */}
         };
 
-    SfxItemPool *pPool = new SfxItemPool("testpool", 0, 3, aItems);
+    SfxItemPool *pPool = new SfxItemPool("testpool", 1, 4, aItems);
     SfxItemPool_Impl *pImpl = SfxItemPool_Impl::GetImpl(pPool);
     CPPUNIT_ASSERT(pImpl != nullptr);
     CPPUNIT_ASSERT(pImpl->maPoolItems.size() == 4);
 
     // Poolable
-    SfxVoidItem aItemZero( 0 );
-    SfxVoidItem aNotherZero( 0 );
+    SfxVoidItem aItemOne( 1 );
+    SfxVoidItem aNotherOne( 1 );
 
     {
         CPPUNIT_ASSERT(pImpl->maPoolItems[0] == nullptr);
-        const SfxPoolItem &rVal = pPool->Put(aItemZero);
-        CPPUNIT_ASSERT(rVal == aItemZero);
+        const SfxPoolItem &rVal = pPool->Put(aItemOne);
+        CPPUNIT_ASSERT(rVal == aItemOne);
         CPPUNIT_ASSERT(pImpl->maPoolItems[0] != nullptr);
-        const SfxPoolItem &rVal2 = pPool->Put(aNotherZero);
+        const SfxPoolItem &rVal2 = pPool->Put(aNotherOne);
         CPPUNIT_ASSERT(rVal2 == rVal);
         CPPUNIT_ASSERT(&rVal2 == &rVal);
 
         // Clones on Put ...
-        CPPUNIT_ASSERT(&rVal2 != &aItemZero);
-        CPPUNIT_ASSERT(&rVal2 != &aNotherZero);
-        CPPUNIT_ASSERT(&rVal != &aItemZero);
-        CPPUNIT_ASSERT(&rVal != &aNotherZero);
+        CPPUNIT_ASSERT(&rVal2 != &aItemOne);
+        CPPUNIT_ASSERT(&rVal2 != &aNotherOne);
+        CPPUNIT_ASSERT(&rVal != &aItemOne);
+        CPPUNIT_ASSERT(&rVal != &aNotherOne);
     }
 
     // non-poolable
-    SfxVoidItem aItemOne( 1 );
-    SfxVoidItem aNotherOne( 1 );
+    SfxVoidItem aItemTwo( 2 );
+    SfxVoidItem aNotherTwo( 2 );
     {
         CPPUNIT_ASSERT(pImpl->maPoolItems[1] == nullptr);
-        const SfxPoolItem &rVal = pPool->Put(aItemOne);
-        CPPUNIT_ASSERT(rVal == aItemOne);
+        const SfxPoolItem &rVal = pPool->Put(aItemTwo);
+        CPPUNIT_ASSERT(rVal == aItemTwo);
         CPPUNIT_ASSERT(pImpl->maPoolItems[1] != nullptr);
 
-        const SfxPoolItem &rVal2 = pPool->Put(aNotherOne);
+        const SfxPoolItem &rVal2 = pPool->Put(aNotherTwo);
         CPPUNIT_ASSERT(rVal2 == rVal);
         CPPUNIT_ASSERT(&rVal2 != &rVal);
     }
 
     // Test rehash
-    for (size_t i = 0; i < pImpl->maPoolItems.size(); ++i)
+    for (SfxPoolItemArray_Impl *pSlice : pImpl->maPoolItems)
     {
-        SfxPoolItemArray_Impl *pSlice = pImpl->maPoolItems[i];
         if (pSlice)
             pSlice->ReHash();
     }
 
     // Test removal.
-    SfxVoidItem aRemoveThree(3);
-    SfxVoidItem aNotherThree(3);
-    const SfxPoolItem &rKeyThree = pPool->Put(aRemoveThree);
-    pPool->Put(aNotherThree);
+    SfxVoidItem aRemoveFour(4);
+    SfxVoidItem aNotherFour(4);
+    const SfxPoolItem &rKeyFour = pPool->Put(aRemoveFour);
+    pPool->Put(aNotherFour);
     CPPUNIT_ASSERT(pImpl->maPoolItems[3]->size() > 0);
     CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
-    pPool->Remove(rKeyThree);
+    pPool->Remove(rKeyFour);
     CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 1);
-    pPool->Put(aNotherThree);
+    pPool->Put(aNotherFour);
     CPPUNIT_ASSERT(pImpl->maPoolItems[3]->maFree.size() == 0);
 }
 
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 2b3d9ff..fc250c3 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -164,7 +164,7 @@ SfxBroadcaster& SfxItemPool::BC()
 SfxItemPool::SfxItemPool
 (
     const OUString&     rName,          /* Pool name to identify in the file format */
-    sal_uInt16          nStartWhich,    /* First WhichId of the Pool */
+    sal_uInt16          nStartWhich,    /* First WhichId of the Pool (must be > 0) */
     sal_uInt16          nEndWhich,      /* Last WhichId of the Pool */
     const SfxItemInfo*  pInfo,         /* SID Map and Item flags */
     SfxPoolItem**       pDefaults,      /* Pointer to static Defaults;


More information about the Libreoffice-commits mailing list