Changeset 724564 for src/Patterns/unittests
- Timestamp:
- Jan 4, 2011, 5:15:14 PM (15 years ago)
- Children:
- 1afcbe
- Parents:
- 746ff1
- git-author:
- Frederik Heber <heber@…> (01/04/11 15:57:33)
- git-committer:
- Frederik Heber <heber@…> (01/04/11 17:15:14)
- Location:
- src/Patterns/unittests
- Files:
-
- 1 added
- 7 edited
- 1 moved
-
CreatorUnitTest.cpp (modified) (1 diff)
-
FactoryUnitTest.cpp (modified) (3 diffs)
-
FactoryUnitTest.hpp (modified) (3 diffs)
-
Makefile.am (modified) (2 diffs)
-
stubs/CommonStub.cpp (moved) (moved from src/Patterns/unittests/stubs/CreatorStub.cpp ) (2 diffs)
-
stubs/CommonStub.hpp (added)
-
stubs/CreatorStub.hpp (modified) (2 diffs)
-
stubs/FactoryStub.cpp (modified) (1 diff)
-
stubs/FactoryStub.hpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/unittests/CreatorUnitTest.cpp
r746ff1 r724564 25 25 26 26 #include "Creator.hpp" 27 #include "stubs/CommonStub.hpp" 27 28 #include "stubs/CreatorStub.hpp" 28 29 -
src/Patterns/unittests/FactoryUnitTest.cpp
r746ff1 r724564 22 22 #include "FactoryUnitTest.hpp" 23 23 24 #include "stubs/CommonStub.hpp" 24 25 #include "stubs/FactoryStub.hpp" 25 26 … … 68 69 void FactoryTest::setUp() 69 70 { 70 FactoryStub::getInstance(); 71 rndA = 72 FactoryStub::getInstance(). 73 PrototypeTable[FactoryStub::Aclass]->create(); 74 rndB = 75 FactoryStub::getInstance(). 76 PrototypeTable[FactoryStub::Bclass]->create(); 71 77 } 72 78 73 79 void FactoryTest::tearDown() 74 80 { 81 delete rndA; 82 delete rndB; 75 83 FactoryStub::purgeInstance(); 76 84 } … … 93 101 } 94 102 95 // check one of the distributions in the table 96 ICreatorStub * rnd = 97 FactoryStub::getInstance(). 98 PrototypeTable[FactoryStub::Aclass]->create(); 103 // check distributions in the table 99 104 CPPUNIT_ASSERT_EQUAL( 100 105 std::string(typeid(teststubs::Aclass).name()), 101 rnd ->name()106 rndA->name() 102 107 ); 103 delete rnd; 108 CPPUNIT_ASSERT_EQUAL( 109 std::string(typeid(teststubs::Bclass).name()), 110 rndB->name() 111 ); 104 112 } 113 114 115 void FactoryTest::getProductEnumTest() 116 { 117 ICreatorStub * rndA_1 = 118 FactoryStub::getInstance().getProduct(FactoryStub::Aclass); 119 CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) ); 120 delete rndA_1; 121 } 122 123 void FactoryTest::getProductNameTest() 124 { 125 ICreatorStub * rndA_1 = 126 FactoryStub::getInstance().getProduct(std::string("Aclass")); 127 CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) ); 128 delete rndA_1; 129 } 130 131 void FactoryTest::getProductTypeTest() 132 { 133 ICreatorStub * rndA_1 = 134 FactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) ); 135 CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) ); 136 delete rndA_1; 137 } -
src/Patterns/unittests/FactoryUnitTest.hpp
r746ff1 r724564 14 14 #endif 15 15 16 class ICreatorStub; 16 17 17 18 #include <cppunit/extensions/HelperMacros.h> … … 21 22 CPPUNIT_TEST_SUITE( FactoryTest ); 22 23 CPPUNIT_TEST ( DistributionTest ); 24 CPPUNIT_TEST ( getProductEnumTest ); 25 CPPUNIT_TEST ( getProductNameTest ); 26 CPPUNIT_TEST ( getProductTypeTest ); 23 27 CPPUNIT_TEST_SUITE_END(); 24 28 … … 28 32 29 33 void DistributionTest(); 34 void getProductEnumTest(); 35 void getProductNameTest(); 36 void getProductTypeTest(); 30 37 31 38 private: 39 ICreatorStub * rndA; 40 ICreatorStub * rndB; 32 41 }; 33 42 -
src/Patterns/unittests/Makefile.am
r746ff1 r724564 37 37 CreatorUnitTest.hpp \ 38 38 ../Creator.hpp \ 39 stubs/CreatorStub.hpp \ 40 stubs/CreatorStub.cpp 39 stubs/CommonStub.cpp \ 40 stubs/CommonStub.hpp \ 41 stubs/CreatorStub.hpp 41 42 CreatorUnitTest_LDADD = $(TESTLIBS) 42 43 … … 44 45 FactoryUnitTest.cpp \ 45 46 FactoryUnitTest.hpp \ 47 stubs/CommonStub.cpp \ 48 stubs/CommonStub.hpp \ 46 49 stubs/CreatorStub.hpp \ 47 stubs/CreatorStub.cpp \48 50 stubs/FactoryStub.hpp \ 49 51 stubs/FactoryStub.cpp \ -
src/Patterns/unittests/stubs/CommonStub.cpp
r746ff1 r724564 7 7 8 8 /* 9 * C reatorStub.cpp9 * CommonStub.cpp 10 10 * 11 11 * Created on: Jan 4, 2011 … … 13 13 */ 14 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 19 20 #include "CommonStub.hpp" 21 15 22 namespace teststubs { 16 class Aclass {}; 17 class Bclass {}; 23 Aclass::Aclass() : 24 counter(0) 25 {}; 26 27 Aclass::~Aclass() {}; 28 29 Bclass::Bclass() : 30 counter(256) 31 {}; 32 33 Bclass::~Bclass() {}; 18 34 }; -
src/Patterns/unittests/stubs/CreatorStub.hpp
r746ff1 r724564 8 8 #ifndef CREATORSTUB_HPP_ 9 9 #define CREATORSTUB_HPP_ 10 11 // include config.h 12 #ifdef HAVE_CONFIG_H 13 #include <config.h> 14 #endif 10 15 11 16 #include <typeinfo> … … 19 24 virtual int getcount() = 0; 20 25 virtual std::string name() = 0; 21 };22 23 namespace teststubs {24 class Aclass25 {26 public:27 Aclass() :28 counter(0)29 {};30 ~Aclass() {};31 32 int counter;33 };34 35 class Bclass36 {37 public:38 Bclass() :39 counter(256)40 {};41 ~Bclass() {};42 43 int counter;44 };45 26 }; 46 27 -
src/Patterns/unittests/stubs/FactoryStub.cpp
r746ff1 r724564 13 13 */ 14 14 15 // include config.h 16 #ifdef HAVE_CONFIG_H 17 #include <config.h> 18 #endif 19 15 20 #include "Singleton_impl.hpp" 16 21 22 #include "CommonStub.hpp" 17 23 #include "FactoryStub.hpp" 18 24 -
src/Patterns/unittests/stubs/FactoryStub.hpp
r746ff1 r724564 9 9 #define FACTORYSTUB_HPP_ 10 10 11 // include config.h 12 #ifdef HAVE_CONFIG_H 13 #include <config.h> 14 #endif 15 11 16 #include "CreatorStub.hpp" 12 17 13 // has to be appear BEFORE Factory.hpp is included!18 // triple has to be appear BEFORE Factory.hpp is included! 14 19 #include "FactoryStub.def" 15 20 #include "FactoryTypeList.hpp" 21 #include "FactoryStub.undef" 22 16 23 #include "Factory.hpp" 17 24 … … 27 34 virtual ~FactoryStub(); 28 35 }; 29 #include "FactoryStub.undef"30 36 31 37 #endif /* FACTORYSTUB_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.
