diff options
Diffstat (limited to 'svl/qa')
-rw-r--r-- | svl/qa/unit/items/test_itempool.cxx | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/svl/qa/unit/items/test_itempool.cxx b/svl/qa/unit/items/test_itempool.cxx index 714c170b445b..38cbda3214da 100644 --- a/svl/qa/unit/items/test_itempool.cxx +++ b/svl/qa/unit/items/test_itempool.cxx @@ -8,6 +8,8 @@ */ #include <svl/itempool.hxx> +#include <svl/itemset.hxx> +#include <svl/itemiter.hxx> #include <poolio.hxx> #include <cppunit/TestAssert.h> @@ -21,13 +23,11 @@ class PoolItemTest : public CppUnit::TestFixture PoolItemTest() {} void testPool(); + void testItemSet(); - // Adds code needed to register the test suite CPPUNIT_TEST_SUITE(PoolItemTest); - CPPUNIT_TEST(testPool); - - // End of test suite definition + CPPUNIT_TEST(testItemSet); CPPUNIT_TEST_SUITE_END(); }; @@ -99,6 +99,52 @@ void PoolItemTest::testPool() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pImpl->maPoolItems[3]->maFree.size()); } +void PoolItemTest::testItemSet() +{ + SfxItemInfo aItems[] = + { { 1, false }, + { 2, false }, + { 3, false }, + { 4, false }, + { 5, false }, + { 6, false }, + { 7, false } + }; + + SfxItemPool *pPool = new SfxItemPool("testpool", 1, 7, aItems); + std::vector<SfxPoolItem*> aDefaults { + new SfxVoidItem(1), + new SfxVoidItem(2), + new SfxVoidItem(3), + new SfxVoidItem(4), + new SfxVoidItem(5), + new SfxVoidItem(6), + new SfxVoidItem(7) + }; + pPool->SetDefaults(&aDefaults); + + SfxItemSet aItemSet(*pPool, 1, 3, 5, 7, 0); + aItemSet.Put(SfxVoidItem(1)); + aItemSet.Put(SfxVoidItem(2)); + aItemSet.Put(SfxVoidItem(3)); + aItemSet.Put(SfxVoidItem(5)); + aItemSet.Put(SfxVoidItem(6)); + aItemSet.Put(SfxVoidItem(7)); + + SfxItemIter aIter(aItemSet); + + CPPUNIT_ASSERT_EQUAL((sal_uInt16)1, aIter.GetFirstWhich()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)7, aIter.GetLastWhich()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)1, aIter.FirstItem()->Which()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)2, aIter.NextItem()->Which()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)3, aIter.NextItem()->Which()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)5, aIter.NextItem()->Which()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)6, aIter.NextItem()->Which()); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)7, aIter.NextItem()->Which()); + CPPUNIT_ASSERT_EQUAL(static_cast<const SfxPoolItem*>(nullptr), aIter.NextItem()); + CPPUNIT_ASSERT_EQUAL(true, aIter.IsAtEnd()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(PoolItemTest); CPPUNIT_PLUGIN_IMPLEMENT(); |