gdb stacktraces for subsequentchecks
[LibreOffice.git] / o3tl / qa / test-vector_pool.cxx
blob6cb207ff26ebb92b465e0a9f3088d1c9ffec9486
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 // autogenerated file with codegen.pl
4 #include "sal/config.h"
5 #include "sal/precppunit.hxx"
7 #include "cppunit/TestAssert.h"
8 #include "cppunit/TestFixture.h"
9 #include "cppunit/extensions/HelperMacros.h"
11 #include <o3tl/vector_pool.hxx>
13 using namespace ::o3tl;
15 class vector_pool_test : public CppUnit::TestFixture
17 public:
18 void testPoolBasics()
20 vector_pool<int> aPool;
22 std::ptrdiff_t nIdx1 = aPool.alloc();
23 std::ptrdiff_t nIdx2 = aPool.alloc();
24 std::ptrdiff_t nIdx3 = aPool.alloc();
26 CPPUNIT_ASSERT_MESSAGE("allocator idx order 1", nIdx1 < nIdx2 );
27 CPPUNIT_ASSERT_MESSAGE("allocator idx order 2", nIdx2 < nIdx3 );
29 aPool.free(nIdx2);
30 aPool.free(nIdx3);
32 nIdx2 = aPool.alloc();
33 nIdx3 = aPool.alloc();
35 CPPUNIT_ASSERT_MESSAGE("allocator idx order 1 after fragmentation", nIdx1 < nIdx3 );
36 CPPUNIT_ASSERT_MESSAGE("allocator idx order 2 after fragmentation", nIdx3 < nIdx2 );
39 void testPoolValueSemantics()
41 vector_pool<int> aPool;
43 std::ptrdiff_t nIdx1 = aPool.store(0);
44 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 1", aPool.get(nIdx1) == 0 );
46 std::ptrdiff_t nIdx2 = aPool.store(1);
47 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2", aPool.get(nIdx2) == 1 );
49 std::ptrdiff_t nIdx3 = aPool.store(2);
50 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3", aPool.get(nIdx3) == 2 );
52 aPool.free(nIdx2);
53 aPool.free(nIdx3);
55 nIdx2 = aPool.store(1);
56 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 2 after fragmentation", aPool.get(nIdx2) == 1 );
58 nIdx3 = aPool.store(2);
59 CPPUNIT_ASSERT_MESSAGE("allocator value semantics 3 after fragmentation", aPool.get(nIdx3) == 2 );
62 // Change the following lines only, if you add, remove or rename
63 // member functions of the current class,
64 // because these macros are need by auto register mechanism.
66 CPPUNIT_TEST_SUITE(vector_pool_test);
67 CPPUNIT_TEST(testPoolBasics);
68 CPPUNIT_TEST(testPoolValueSemantics);
69 CPPUNIT_TEST_SUITE_END();
72 // -----------------------------------------------------------------------------
73 CPPUNIT_TEST_SUITE_REGISTRATION(vector_pool_test);
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */