update dev300-m58
[ooovba.git] / o3tl / qa / test-cow_wrapper.cxx
blob459dc87d559735fb7b5eb9c2aa131bd82f935afb
1 // autogenerated file with codegen.pl
3 #include <cppunit/simpleheader.hxx>
5 #include "cow_wrapper_clients.hxx"
7 using namespace ::o3tl;
8 using namespace ::o3tltests;
11 class cow_wrapper_test : public CppUnit::TestFixture
13 public:
14 template< class T > void test( T& rTestObj1, T& rTestObj2, T& rTestObj3 )
16 CPPUNIT_ASSERT_MESSAGE("rTestObj1 is unique",
17 rTestObj1.is_unique() );
18 CPPUNIT_ASSERT_MESSAGE("rTestObj2 is unique",
19 rTestObj2.is_unique() );
20 CPPUNIT_ASSERT_MESSAGE("rTestObj3 is unique",
21 rTestObj3.is_unique() );
23 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj2",
24 rTestObj1 != rTestObj2 );
25 CPPUNIT_ASSERT_MESSAGE("rTestObj2 != rTestObj3",
26 rTestObj2 != rTestObj3 );
27 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj3",
28 rTestObj1 != rTestObj3 );
29 CPPUNIT_ASSERT_MESSAGE("rTestObj1 < rTestObj2",
30 rTestObj1 < rTestObj2 );
31 CPPUNIT_ASSERT_MESSAGE("rTestObj2 < rTestObj3",
32 rTestObj2 < rTestObj3 );
34 rTestObj2 = rTestObj1;
35 rTestObj3 = rTestObj1;
36 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
37 rTestObj1 == rTestObj2 );
38 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
39 rTestObj1 == rTestObj3 );
40 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 3",
41 rTestObj1.use_count() == 3 );
42 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 3",
43 rTestObj2.use_count() == 3 );
44 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 3",
45 rTestObj3.use_count() == 3 );
47 rTestObj2.makeUnique();
48 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
49 rTestObj1 == rTestObj2 );
50 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
51 rTestObj1 == rTestObj3 );
52 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
53 rTestObj1.use_count() == 2 );
54 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 1",
55 rTestObj2.use_count() == 1 );
56 CPPUNIT_ASSERT_MESSAGE("rTestObj2.is_unique()",
57 rTestObj2.is_unique() );
58 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 2",
59 rTestObj3.use_count() == 2 );
61 rTestObj2.swap( rTestObj3 );
62 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
63 rTestObj1 == rTestObj2 );
64 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
65 rTestObj1 == rTestObj3 );
66 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
67 rTestObj1.use_count() == 2 );
68 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 2",
69 rTestObj2.use_count() == 2 );
70 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 1",
71 rTestObj3.use_count() == 1 );
72 CPPUNIT_ASSERT_MESSAGE("rTestObj3.is_unique()",
73 rTestObj3.is_unique() );
76 void testCowWrapper()
78 // setup
79 cow_wrapper_client1 aTestObj1;
80 cow_wrapper_client1 aTestObj2;
81 cow_wrapper_client1 aTestObj3;
83 cow_wrapper_client2 aTestObj4;
84 cow_wrapper_client2 aTestObj5;
85 cow_wrapper_client2 aTestObj6;
87 cow_wrapper_client3 aTestObj7;
88 cow_wrapper_client3 aTestObj8;
89 cow_wrapper_client3 aTestObj9;
92 aTestObj1 = cow_wrapper_client1( 1 );
93 aTestObj2.modify( 2 );
94 aTestObj3.modify( 3 );
96 aTestObj4 = cow_wrapper_client2( 4 );
97 aTestObj5.modify( 5 );
98 aTestObj6.modify( 6 );
100 aTestObj7 = cow_wrapper_client3( 7 );
101 aTestObj8.modify( 8 );
102 aTestObj9.modify( 9 );
104 // all three temporaries are dead now
106 // test
107 test( aTestObj1, aTestObj2, aTestObj3 );
108 test( aTestObj4, aTestObj5, aTestObj6 );
109 test( aTestObj7, aTestObj8, aTestObj9 );
112 // Change the following lines only, if you add, remove or rename
113 // member functions of the current class,
114 // because these macros are need by auto register mechanism.
116 CPPUNIT_TEST_SUITE(cow_wrapper_test);
117 CPPUNIT_TEST(testCowWrapper);
118 CPPUNIT_TEST_SUITE_END();
121 // -----------------------------------------------------------------------------
122 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(cow_wrapper_test, "cow_wrapper_test");
125 // -----------------------------------------------------------------------------
127 // this macro creates an empty function, which will called by the RegisterAllFunctions()
128 // to let the user the possibility to also register some functions by hand.
129 void RegisterAdditionalFunctions(FktRegFuncPtr )
132 // NOADDITIONAL;