| [197e13] | 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| [0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| [197e13] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * MenuDescription_ActionRegistry_ConsistencyUnitTest.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Nov 25, 2009
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 | #include <cppunit/CompilerOutputter.h>
|
|---|
| 22 | #include <cppunit/extensions/TestFactoryRegistry.h>
|
|---|
| 23 | #include <cppunit/ui/text/TestRunner.h>
|
|---|
| 24 |
|
|---|
| 25 | #include "Actions/Action.hpp"
|
|---|
| 26 | #include "Actions/ActionRegistry.hpp"
|
|---|
| [3139b2] | 27 | #include "Actions/ActionTrait.hpp"
|
|---|
| [197e13] | 28 |
|
|---|
| 29 | #include "MenuDescription_ActionRegistry_ConsistencyUnitTest.hpp"
|
|---|
| 30 |
|
|---|
| [ce7fdc] | 31 | using namespace MoleCuilder;
|
|---|
| 32 |
|
|---|
| [197e13] | 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( MenuDescription_ActionRegistry_ConsistencyTest );
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | void MenuDescription_ActionRegistry_ConsistencyTest::setUp()
|
|---|
| 44 | {
|
|---|
| 45 | AR = ActionRegistry::getPointer();
|
|---|
| 46 | };
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 | void MenuDescription_ActionRegistry_ConsistencyTest::tearDown()
|
|---|
| 50 | {
|
|---|
| 51 | ActionRegistry::purgeInstance();
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | /** UnitTest for consistency.
|
|---|
| 55 | * we check that we have the same keys in each of MenuSet, MenuDescription and MenuNameMap.
|
|---|
| 56 | */
|
|---|
| 57 | void MenuDescription_ActionRegistry_ConsistencyTest::ConsistencyCheck()
|
|---|
| 58 | {
|
|---|
| 59 | std::set <std::string> MenuNames_from_ActionRegistry;
|
|---|
| 60 |
|
|---|
| 61 | // go through all Actions and gather menu names
|
|---|
| 62 | for (ActionRegistry::const_iterator iter = AR->getBeginIter();
|
|---|
| 63 | iter != AR->getEndIter();
|
|---|
| 64 | ++iter) {
|
|---|
| 65 | const std::string &MenuName = (iter->second)->Traits.getMenuName();
|
|---|
| 66 | MenuNames_from_ActionRegistry.insert(MenuName);
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | for (std::set <std::string>::const_iterator ARiter = MenuNames_from_ActionRegistry.begin();
|
|---|
| 70 | ARiter != MenuNames_from_ActionRegistry.end();
|
|---|
| 71 | ++ARiter) {
|
|---|
| 72 | std::string const MenuName = *ARiter;
|
|---|
| 73 | CPPUNIT_ASSERT_MESSAGE(MenuName
|
|---|
| 74 | +" cannot be found in the MenuDescription::MenuDescriptionsMap.\n"
|
|---|
| 75 | +"Have you added an entry to MenuDescriptionsMap of MenuDescription for this menu?",
|
|---|
| 76 | md.MenuDescriptionsMap->count(MenuName));
|
|---|
| 77 | CPPUNIT_ASSERT_MESSAGE(MenuName
|
|---|
| 78 | +" cannot be found in the MenuDescription::MenuPositionMap.\n"
|
|---|
| 79 | +"Have you added an entry to MenuPositionMap of MenuDescription for this menu?",
|
|---|
| 80 | md.MenuPositionMap->count(MenuName));
|
|---|
| 81 | CPPUNIT_ASSERT_MESSAGE(MenuName
|
|---|
| 82 | +" cannot be found in the MenuDescription::MenuNameMap.\n"
|
|---|
| 83 | +"Have you added an entry to MenuNameMap of MenuDescription for this menu?",
|
|---|
| 84 | md.MenuNameMap->count(MenuName));
|
|---|
| 85 | }
|
|---|
| 86 | };
|
|---|