Changeset fe056c for src/Patterns/unittests
- Timestamp:
- Jan 16, 2011, 6:38:25 PM (15 years ago)
- Children:
- d1a85d
- Parents:
- 56d62f
- git-author:
- Frederik Heber <heber@…> (01/16/11 18:36:28)
- git-committer:
- Frederik Heber <heber@…> (01/16/11 18:38:25)
- Location:
- src/Patterns/unittests
- Files:
-
- 4 added
- 3 edited
-
Makefile.am (modified) (1 diff)
-
RegistryUnitTest.cpp (modified) (2 diffs)
-
RegistryUnitTest.hpp (modified) (2 diffs)
-
stubs/CommonNamedStub.cpp (added)
-
stubs/CommonNamedStub.hpp (added)
-
stubs/RegistryStub.cpp (added)
-
stubs/RegistryStub.hpp (added)
Legend:
- Unmodified
- Added
- Removed
-
src/Patterns/unittests/Makefile.am
r56d62f rfe056c 126 126 RegistryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 127 127 RegistryUnitTest.cpp \ 128 RegistryUnitTest.hpp 129 #nodist_RegistryUnitTest_SOURCES = 130 #RegistryUnitTest_LDADD = $(TESTLIBS) 128 RegistryUnitTest.hpp \ 129 stubs/CommonNamedStub.cpp \ 130 stubs/CommonNamedStub.hpp \ 131 stubs/RegistryStub.cpp \ 132 stubs/RegistryStub.hpp 133 nodist_RegistryUnitTest_SOURCES = \ 134 Registry.hpp \ 135 Registry_impl.hpp 136 RegistryUnitTest_LDADD = $(TESTLIBS) 131 137 132 138 SingletonUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ -
src/Patterns/unittests/RegistryUnitTest.cpp
r56d62f rfe056c 24 24 #include <typeinfo> 25 25 26 #include "stubs/CommonNamedStub.hpp" 27 #include "stubs/RegistryStub.hpp" 28 29 #include "Assert.hpp" 30 26 31 #include "RegistryUnitTest.hpp" 27 32 … … 37 42 38 43 void RegistryTest::setUp() 39 {}; 44 { 45 ASSERT_DO(Assert::Throw); 46 registry = new RegistryStub; 47 }; 40 48 41 49 42 50 void RegistryTest::tearDown() 43 {}; 51 { 52 delete registry; 53 }; 44 54 45 55 void RegistryTest::InOutCheck() 46 56 { 47 CPPUNIT_ASSERT(true); 57 // create two test instances to put into the registry 58 teststubs::ANamedclass *instanceA = new teststubs::ANamedclass; 59 teststubs::BNamedclass *instanceB = new teststubs::BNamedclass; 60 teststubs::INamedclass *testinstance = NULL; 61 62 // register both instances 63 registry->registerInstance(instanceA); 64 registry->registerInstance(instanceB); 65 66 // obtain Aclass and see if it matches 67 testinstance = registry->getByName("ANamedclass"); 68 CPPUNIT_ASSERT( testinstance == instanceA ); 69 70 // unregister Aclass and see if there's no more match 71 registry->unregisterInstance(instanceA); 72 testinstance = NULL; 73 #ifndef NDEBUG 74 CPPUNIT_ASSERT_THROW((testinstance = registry->getByName("ANamedclass")),Assert::AssertionFailure); 75 #else 76 testinstance = registry->getByName("ANamedclass"); 77 #endif 78 CPPUNIT_ASSERT( testinstance == NULL ); 79 80 // obtain Bclass and see if it matches 81 testinstance = registry->getByName("BNamedclass"); 82 CPPUNIT_ASSERT( testinstance == instanceB ); 83 84 // unregister Aclass and see if there's no more match 85 registry->unregisterInstance(instanceB); 86 testinstance = NULL; 87 #ifndef NDEBUG 88 CPPUNIT_ASSERT_THROW((testinstance = registry->getByName("BNamedclass")),Assert::AssertionFailure); 89 #else 90 testinstance = registry->getByName("BNamedclass"); 91 #endif 92 CPPUNIT_ASSERT( testinstance == NULL ); 93 CPPUNIT_ASSERT( testinstance == NULL ); 94 95 // check that registry is empty 96 CPPUNIT_ASSERT( registry->getBeginIter() == registry->getEndIter() ); 97 98 delete instanceA; 99 delete instanceB; 48 100 } -
src/Patterns/unittests/RegistryUnitTest.hpp
r56d62f rfe056c 16 16 #include <cppunit/extensions/HelperMacros.h> 17 17 18 class RegistryStub; 18 19 19 20 /********************************************** Test classes **************************************/ … … 31 32 32 33 private: 34 RegistryStub* registry; 33 35 }; 34 36
Note:
See TracChangeset
for help on using the changeset viewer.
