| 1 | /*
 | 
|---|
| 2 |  * Project: MoleCuilder
 | 
|---|
| 3 |  * Description: creates and alters molecular systems
 | 
|---|
| 4 |  * Copyright (C)  2010 University of Bonn. All rights reserved.
 | 
|---|
| 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
| 6 |  */
 | 
|---|
| 7 | 
 | 
|---|
| 8 | /*
 | 
|---|
| 9 |  * ActionRegistryUnitTest.cpp
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  *  Created on: Dec 15, 2010
 | 
|---|
| 12 |  *      Author: heber
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | // include config.h
 | 
|---|
| 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
| 17 | #include <config.h>
 | 
|---|
| 18 | #endif
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
| 21 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
| 22 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
| 23 | 
 | 
|---|
| 24 | #include "ActionRegistryUnitTest.hpp"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | #include <typeinfo>
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include "Actions/ActionRegistry.hpp"
 | 
|---|
| 29 | #include "Actions/ActionTraits.hpp"
 | 
|---|
| 30 | #include "Actions/OptionRegistry.hpp"
 | 
|---|
| 31 | #include "Actions/OptionTrait.hpp"
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #ifdef HAVE_TESTRUNNER
 | 
|---|
| 34 | #include "UnitTestMain.hpp"
 | 
|---|
| 35 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
| 36 | 
 | 
|---|
| 37 | /********************************************** Test classes **************************************/
 | 
|---|
| 38 | 
 | 
|---|
| 39 | // Registers the fixture into the 'registry'
 | 
|---|
| 40 | CPPUNIT_TEST_SUITE_REGISTRATION( ActionRegistryTest );
 | 
|---|
| 41 | 
 | 
|---|
| 42 | 
 | 
|---|
| 43 | void ActionRegistryTest::setUp()
 | 
|---|
| 44 | {};
 | 
|---|
| 45 | 
 | 
|---|
| 46 | 
 | 
|---|
| 47 | void ActionRegistryTest::tearDown()
 | 
|---|
| 48 | {};
 | 
|---|
| 49 | 
 | 
|---|
| 50 | void ActionRegistryTest::CheckDoublyUsedShortforms()
 | 
|---|
| 51 | {
 | 
|---|
| 52 |   std::map <std::string, std::string> result;
 | 
|---|
| 53 | 
 | 
|---|
| 54 |   ActionRegistry &AR = ActionRegistry::getInstance();
 | 
|---|
| 55 |   for (ActionRegistry::const_iterator iter = AR.getBeginIter(); iter != AR.getEndIter(); ++iter) {
 | 
|---|
| 56 |     if ((iter->second)->Traits.hasShortForm()) {
 | 
|---|
| 57 |       ASSERT(result.find((iter->second)->Traits.getShortForm()) == result.end(),
 | 
|---|
| 58 |           "Short form "+toString((iter->second)->Traits.getShortForm())+
 | 
|---|
| 59 |           " for action "+toString(iter->first)+" already present from "+
 | 
|---|
| 60 |           std::string(result[(iter->second)->Traits.getShortForm()])+"!");
 | 
|---|
| 61 |       result[(iter->second)->Traits.getShortForm()] = (iter->second)->getName();
 | 
|---|
| 62 |     }
 | 
|---|
| 63 |   }
 | 
|---|
| 64 | }
 | 
|---|