1 // autogenerated file with codegen.pl
4 #include "cppunit/TestAssert.h"
5 #include "cppunit/TestFixture.h"
6 #include "cppunit/extensions/HelperMacros.h"
7 #include "cppunit/plugin/TestPlugIn.h"
8 #include "postextstl.h"
10 #include "cow_wrapper_clients.hxx"
12 using namespace ::o3tl
;
13 using namespace ::o3tltests
;
16 class cow_wrapper_test
: public CppUnit::TestFixture
19 template< class T
> void test( T
& rTestObj1
, T
& rTestObj2
, T
& rTestObj3
)
21 CPPUNIT_ASSERT_MESSAGE("rTestObj1 is unique",
22 rTestObj1
.is_unique() );
23 CPPUNIT_ASSERT_MESSAGE("rTestObj2 is unique",
24 rTestObj2
.is_unique() );
25 CPPUNIT_ASSERT_MESSAGE("rTestObj3 is unique",
26 rTestObj3
.is_unique() );
28 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj2",
29 rTestObj1
!= rTestObj2
);
30 CPPUNIT_ASSERT_MESSAGE("rTestObj2 != rTestObj3",
31 rTestObj2
!= rTestObj3
);
32 CPPUNIT_ASSERT_MESSAGE("rTestObj1 != rTestObj3",
33 rTestObj1
!= rTestObj3
);
34 CPPUNIT_ASSERT_MESSAGE("rTestObj1 < rTestObj2",
35 rTestObj1
< rTestObj2
);
36 CPPUNIT_ASSERT_MESSAGE("rTestObj2 < rTestObj3",
37 rTestObj2
< rTestObj3
);
39 rTestObj2
= rTestObj1
;
40 rTestObj3
= rTestObj1
;
41 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
42 rTestObj1
== rTestObj2
);
43 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
44 rTestObj1
== rTestObj3
);
45 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 3",
46 rTestObj1
.use_count() == 3 );
47 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 3",
48 rTestObj2
.use_count() == 3 );
49 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 3",
50 rTestObj3
.use_count() == 3 );
52 rTestObj2
.makeUnique();
53 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
54 rTestObj1
== rTestObj2
);
55 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
56 rTestObj1
== rTestObj3
);
57 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
58 rTestObj1
.use_count() == 2 );
59 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 1",
60 rTestObj2
.use_count() == 1 );
61 CPPUNIT_ASSERT_MESSAGE("rTestObj2.is_unique()",
62 rTestObj2
.is_unique() );
63 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 2",
64 rTestObj3
.use_count() == 2 );
66 rTestObj2
.swap( rTestObj3
);
67 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj2",
68 rTestObj1
== rTestObj2
);
69 CPPUNIT_ASSERT_MESSAGE("rTestObj1 == rTestObj3",
70 rTestObj1
== rTestObj3
);
71 CPPUNIT_ASSERT_MESSAGE("rTestObj1.use_count() == 2",
72 rTestObj1
.use_count() == 2 );
73 CPPUNIT_ASSERT_MESSAGE("rTestObj2.use_count() == 2",
74 rTestObj2
.use_count() == 2 );
75 CPPUNIT_ASSERT_MESSAGE("rTestObj3.use_count() == 1",
76 rTestObj3
.use_count() == 1 );
77 CPPUNIT_ASSERT_MESSAGE("rTestObj3.is_unique()",
78 rTestObj3
.is_unique() );
84 cow_wrapper_client1 aTestObj1
;
85 cow_wrapper_client1 aTestObj2
;
86 cow_wrapper_client1 aTestObj3
;
88 cow_wrapper_client2 aTestObj4
;
89 cow_wrapper_client2 aTestObj5
;
90 cow_wrapper_client2 aTestObj6
;
92 cow_wrapper_client3 aTestObj7
;
93 cow_wrapper_client3 aTestObj8
;
94 cow_wrapper_client3 aTestObj9
;
97 aTestObj1
= cow_wrapper_client1( 1 );
98 aTestObj2
.modify( 2 );
99 aTestObj3
.modify( 3 );
101 aTestObj4
= cow_wrapper_client2( 4 );
102 aTestObj5
.modify( 5 );
103 aTestObj6
.modify( 6 );
105 aTestObj7
= cow_wrapper_client3( 7 );
106 aTestObj8
.modify( 8 );
107 aTestObj9
.modify( 9 );
109 // all three temporaries are dead now
112 test( aTestObj1
, aTestObj2
, aTestObj3
);
113 test( aTestObj4
, aTestObj5
, aTestObj6
);
114 test( aTestObj7
, aTestObj8
, aTestObj9
);
117 // Change the following lines only, if you add, remove or rename
118 // member functions of the current class,
119 // because these macros are need by auto register mechanism.
121 CPPUNIT_TEST_SUITE(cow_wrapper_test
);
122 CPPUNIT_TEST(testCowWrapper
);
123 CPPUNIT_TEST_SUITE_END();
126 // -----------------------------------------------------------------------------
127 CPPUNIT_TEST_SUITE_REGISTRATION(cow_wrapper_test
);
129 CPPUNIT_PLUGIN_IMPLEMENT();