| 1 | /* | 
|---|
| 2 | * Project: MoleCuilder | 
|---|
| 3 | * Description: creates and alters molecular systems | 
|---|
| 4 | * Copyright (C)  2010-2012 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/ActionTrait.hpp" | 
|---|
| 30 | #include "Actions/OptionRegistry.hpp" | 
|---|
| 31 | #include "Actions/OptionTrait.hpp" | 
|---|
| 32 |  | 
|---|
| 33 | using namespace MoleCuilder; | 
|---|
| 34 |  | 
|---|
| 35 | #ifdef HAVE_TESTRUNNER | 
|---|
| 36 | #include "UnitTestMain.hpp" | 
|---|
| 37 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
| 38 |  | 
|---|
| 39 | /********************************************** Test classes **************************************/ | 
|---|
| 40 |  | 
|---|
| 41 | // Registers the fixture into the 'registry' | 
|---|
| 42 | CPPUNIT_TEST_SUITE_REGISTRATION( ActionRegistryTest ); | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | void ActionRegistryTest::setUp() | 
|---|
| 46 | { | 
|---|
| 47 | ActionRegistry::getInstance(); | 
|---|
| 48 | }; | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | void ActionRegistryTest::tearDown() | 
|---|
| 52 | { | 
|---|
| 53 | ActionRegistry::purgeInstance(); | 
|---|
| 54 | }; | 
|---|
| 55 |  | 
|---|
| 56 | void ActionRegistryTest::CheckDoublyUsedShortforms() | 
|---|
| 57 | { | 
|---|
| 58 | std::map <std::string, std::string> result; | 
|---|
| 59 |  | 
|---|
| 60 | ActionRegistry &AR = ActionRegistry::getInstance(); | 
|---|
| 61 | for (ActionRegistry::const_iterator iter = AR.getBeginIter(); iter != AR.getEndIter(); ++iter) { | 
|---|
| 62 | if ((iter->second)->Traits.hasShortForm()) { | 
|---|
| 63 | ASSERT(result.find((iter->second)->Traits.getShortForm()) == result.end(), | 
|---|
| 64 | "Short form "+toString((iter->second)->Traits.getShortForm())+ | 
|---|
| 65 | " for action "+toString(iter->first)+" already present from "+ | 
|---|
| 66 | std::string(result[(iter->second)->Traits.getShortForm()])+"!"); | 
|---|
| 67 | result[(iter->second)->Traits.getShortForm()] = (iter->second)->getName(); | 
|---|
| 68 | } | 
|---|
| 69 | } | 
|---|
| 70 | } | 
|---|