merge the formfield patch from ooo-build
[ooovba.git] / o3tl / qa / test-vector_pool.cxx
blob46f188ee0f9d9246cad48e07823e1fd083bcc81d
1 // autogenerated file with codegen.pl
3 #include <cppunit/simpleheader.hxx>
5 #include <o3tl/vector_pool.hxx>
7 using namespace ::o3tl;
9 class vector_pool_test : public CppUnit::TestFixture
11 public:
12 void testPoolBasics()
14 vector_pool<int> aPool;
16 std::ptrdiff_t nIdx1 = aPool.alloc();
17 std::ptrdiff_t nIdx2 = aPool.alloc();
18 std::ptrdiff_t nIdx3 = aPool.alloc();
20 CPPUNIT_ASSERT_MESSAGE("allocator idx order 1", nIdx1 < nIdx2 );
21 CPPUNIT_ASSERT_MESSAGE("allocator idx order 2", nIdx2 < nIdx3 );
23 aPool.free(nIdx2);
24 aPool.free(nIdx3);
26 nIdx2 = aPool.alloc();
27 nIdx3 = aPool.alloc();
29 CPPUNIT_ASSERT_MESSAGE("allocator idx order 1 after fragmentation", nIdx1 < nIdx3 );
30 CPPUNIT_ASSERT_MESSAGE("allocator idx order 2 after fragmentation", nIdx3 < nIdx2 );
33 void testPoolValueSemantics()
35 vector_pool<int> aPool;
37 std::ptrdiff_t nIdx1 = aPool.store(0);
38 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 1", aPool.get(nIdx1) == 0 );
40 std::ptrdiff_t nIdx2 = aPool.store(1);
41 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2", aPool.get(nIdx2) == 1 );
43 std::ptrdiff_t nIdx3 = aPool.store(2);
44 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3", aPool.get(nIdx3) == 2 );
46 aPool.free(nIdx2);
47 aPool.free(nIdx3);
49 nIdx2 = aPool.store(1);
50 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2 after fragmentation", aPool.get(nIdx2) == 1 );
52 nIdx3 = aPool.store(2);
53 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3 after fragmentation", aPool.get(nIdx3) == 2 );
56 // Change the following lines only, if you add, remove or rename
57 // member functions of the current class,
58 // because these macros are need by auto register mechanism.
60 CPPUNIT_TEST_SUITE(vector_pool_test);
61 CPPUNIT_TEST(testPoolBasics);
62 CPPUNIT_TEST(testPoolValueSemantics);
63 CPPUNIT_TEST_SUITE_END();
66 // -----------------------------------------------------------------------------
67 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(vector_pool_test, "vector pool test");
70 // -----------------------------------------------------------------------------
72 // NOADDITIONAL;