merged tag ooo/OOO330_m14
[LibreOffice.git] / o3tl / qa / test-cow_wrapper.cxx
blob84d615fca3db4533a0bf631c6c58becf84e14fad
1 // autogenerated file with codegen.pl
3 #include "cppunit/TestAssert.h"
4 #include "cppunit/TestFixture.h"
5 #include "cppunit/extensions/HelperMacros.h"
6 #include "cppunit/plugin/TestPlugIn.h"
8 #include "cow_wrapper_clients.hxx"
10 using namespace ::o3tl;
11 using namespace ::o3tltests;
14 class cow_wrapper_test : public CppUnit::TestFixture
16 public:
17 template< class T > void test( T& rTestObj1, T& rTestObj2, T& rTestObj3 )
19 CPPUNIT_ASSERT_MESSAGE("rTestObj1 is unique",
20 rTestObj1.is_unique() );
21 CPPUNIT_ASSERT_MESSAGE("rTestObj2 is unique",
22 rTestObj2.is_unique() );
23 CPPUNIT_ASSERT_MESSAGE("rTestObj3 is unique",
24 rTestObj3.is_unique() );
26 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj2",
27 rTestObj1 != rTestObj2 );
28 CPPUNIT_ASSERT_MESSAGE("rTestObj2 != rTestObj3",
29 rTestObj2 != rTestObj3 );
30 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj3",
31 rTestObj1 != rTestObj3 );
32 CPPUNIT_ASSERT_MESSAGE("rTestObj1 < rTestObj2",
33 rTestObj1 < rTestObj2 );
34 CPPUNIT_ASSERT_MESSAGE("rTestObj2 < rTestObj3",
35 rTestObj2 < rTestObj3 );
37 rTestObj2 = rTestObj1;
38 rTestObj3 = rTestObj1;
39 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
40 rTestObj1 == rTestObj2 );
41 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
42 rTestObj1 == rTestObj3 );
43 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 3",
44 rTestObj1.use_count() == 3 );
45 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 3",
46 rTestObj2.use_count() == 3 );
47 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 3",
48 rTestObj3.use_count() == 3 );
50 rTestObj2.makeUnique();
51 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
52 rTestObj1 == rTestObj2 );
53 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
54 rTestObj1 == rTestObj3 );
55 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
56 rTestObj1.use_count() == 2 );
57 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 1",
58 rTestObj2.use_count() == 1 );
59 CPPUNIT_ASSERT_MESSAGE("rTestObj2.is_unique()",
60 rTestObj2.is_unique() );
61 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 2",
62 rTestObj3.use_count() == 2 );
64 rTestObj2.swap( rTestObj3 );
65 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
66 rTestObj1 == rTestObj2 );
67 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
68 rTestObj1 == rTestObj3 );
69 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
70 rTestObj1.use_count() == 2 );
71 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 2",
72 rTestObj2.use_count() == 2 );
73 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 1",
74 rTestObj3.use_count() == 1 );
75 CPPUNIT_ASSERT_MESSAGE("rTestObj3.is_unique()",
76 rTestObj3.is_unique() );
79 void testCowWrapper()
81 // setup
82 cow_wrapper_client1 aTestObj1;
83 cow_wrapper_client1 aTestObj2;
84 cow_wrapper_client1 aTestObj3;
86 cow_wrapper_client2 aTestObj4;
87 cow_wrapper_client2 aTestObj5;
88 cow_wrapper_client2 aTestObj6;
90 cow_wrapper_client3 aTestObj7;
91 cow_wrapper_client3 aTestObj8;
92 cow_wrapper_client3 aTestObj9;
95 aTestObj1 = cow_wrapper_client1( 1 );
96 aTestObj2.modify( 2 );
97 aTestObj3.modify( 3 );
99 aTestObj4 = cow_wrapper_client2( 4 );
100 aTestObj5.modify( 5 );
101 aTestObj6.modify( 6 );
103 aTestObj7 = cow_wrapper_client3( 7 );
104 aTestObj8.modify( 8 );
105 aTestObj9.modify( 9 );
107 // all three temporaries are dead now
109 // test
110 test( aTestObj1, aTestObj2, aTestObj3 );
111 test( aTestObj4, aTestObj5, aTestObj6 );
112 test( aTestObj7, aTestObj8, aTestObj9 );
115 // Change the following lines only, if you add, remove or rename
116 // member functions of the current class,
117 // because these macros are need by auto register mechanism.
119 CPPUNIT_TEST_SUITE(cow_wrapper_test);
120 CPPUNIT_TEST(testCowWrapper);
121 CPPUNIT_TEST_SUITE_END();
124 // -----------------------------------------------------------------------------
125 CPPUNIT_TEST_SUITE_REGISTRATION(cow_wrapper_test);
127 CPPUNIT_PLUGIN_IMPLEMENT();