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