Changeset 9f39db for src/Patterns/unittests/CreatorUnitTest.cpp
- Timestamp:
- Jan 6, 2011, 11:47:13 PM (15 years ago)
- Children:
- 8dd38e
- Parents:
- 567640
- File:
-
- 1 edited
-
src/Patterns/unittests/CreatorUnitTest.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/unittests/CreatorUnitTest.cpp
r567640 r9f39db 23 23 24 24 #include "Assert.hpp" 25 26 #include "Creator.hpp"27 #include "stubs/CommonStub.hpp"28 #include "stubs/CreatorStub.hpp"29 25 30 26 #include <boost/nondet_random.hpp> … … 73 69 void CreatorTest::setUp() 74 70 { 71 testingA1 = NULL; 72 testingA2 = NULL; 73 testingB1 = NULL; 74 testingB2 = NULL; 75 75 } 76 76 77 77 void CreatorTest::tearDown() 78 78 { 79 delete testingA1; 80 delete testingA2; 81 delete testingB1; 82 delete testingB2; 79 83 } 80 84 81 85 void CreatorTest::CreationTest() 82 86 { 83 class CreatorStub<teststubs::Aclass> teststubA; 84 class CreatorStub<teststubs::Bclass> teststubB; 85 86 ICreatorStub* testingA1 = teststubA.create(); 87 ICreatorStub* testingA2 = teststubA.create(); 88 ICreatorStub* testingB = teststubB.create(); 87 testingA1 = teststubA.create(); 88 testingA2 = teststubA.create(); 89 testingB1 = teststubB.create(); 89 90 90 91 // instance is different … … 92 93 CPPUNIT_ASSERT( &teststubA != testingA2 ); 93 94 CPPUNIT_ASSERT( testingA1 != testingA2 ); 94 CPPUNIT_ASSERT( &teststubB != testingB );95 CPPUNIT_ASSERT( &teststubB != testingB1 ); 95 96 96 97 // type is the same ... 97 98 CPPUNIT_ASSERT_EQUAL( typeid(teststubA).name(), typeid(*testingA1).name() ); 98 99 CPPUNIT_ASSERT_EQUAL( typeid(*testingA1).name(), typeid(*testingA2).name() ); 99 CPPUNIT_ASSERT_EQUAL( typeid(teststubB).name(), typeid(*testingB ).name() );100 CPPUNIT_ASSERT_EQUAL( typeid(teststubB).name(), typeid(*testingB1).name() ); 100 101 101 102 // ... for the same particular type only! 102 103 // (RTTI knows about the true complex type!) 103 CPPUNIT_ASSERT( typeid(*testingB ).name() != typeid(*testingA1).name() );104 CPPUNIT_ASSERT( typeid(*testingB ).name() != typeid(*testingA2).name() );104 CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA1).name() ); 105 CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA2).name() ); 105 106 106 107 // but not for different encapsulated types 107 CPPUNIT_ASSERT( typeid(teststubA).name() != typeid(*testingB ).name() );108 CPPUNIT_ASSERT( typeid(teststubA).name() != typeid(*testingB1).name() ); 108 109 CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA1).name() ); 109 110 CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA2).name() ); 110 111 111 delete testingA1;112 delete testingA2;113 delete testingB;114 112 } 115 113 116 114 void CreatorTest::IndividualityTest() 117 115 { 118 class CreatorStub<teststubs::Aclass> teststubA;119 class CreatorStub<teststubs::Bclass> teststubB;120 116 teststubA.count(); 121 117 teststubB.count(); 122 118 teststubB.count(); 123 119 124 ICreatorStub*testingA1 = teststubA.create();125 ICreatorStub*testingA2 = teststubA.create();126 ICreatorStub*testingB1 = teststubB.create();127 ICreatorStub*testingB2 = teststubB.create();120 testingA1 = teststubA.create(); 121 testingA2 = teststubA.create(); 122 testingB1 = teststubB.create(); 123 testingB2 = teststubB.create(); 128 124 129 125 // content is the same (prototype has been copied) … … 140 136 testingB2->count(); 141 137 CPPUNIT_ASSERT( testingB1->getcount() != testingB2->getcount()); 142 143 delete testingA1;144 delete testingA2;145 delete testingB1;146 delete testingB2;147 138 }
Note:
See TracChangeset
for help on using the changeset viewer.
