| [ec0acc] | 1 | /* | 
|---|
|  | 2 | * Project: MoleCuilder | 
|---|
|  | 3 | * Description: creates and alters molecular systems | 
|---|
| [0aa122] | 4 | * Copyright (C)  2010-2012 University of Bonn. All rights reserved. | 
|---|
| [ec0acc] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | /* | 
|---|
|  | 9 | * ParameterStorageUnitTest.cpp | 
|---|
|  | 10 | * | 
|---|
|  | 11 | *  Created on: Sep 30, 2011 | 
|---|
|  | 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 "ParameterStorageUnitTest.hpp" | 
|---|
|  | 25 |  | 
|---|
|  | 26 | #include <typeinfo> | 
|---|
|  | 27 |  | 
|---|
|  | 28 | #include "Parser/Parameters/ParameterStorage.hpp" | 
|---|
|  | 29 | #include "Parser/Parameters/ContinuousParameter.hpp" | 
|---|
|  | 30 | #include "Parser/Parameters/DiscreteParameter.hpp" | 
|---|
|  | 31 |  | 
|---|
|  | 32 | #ifdef HAVE_TESTRUNNER | 
|---|
|  | 33 | #include "UnitTestMain.hpp" | 
|---|
|  | 34 | #endif /*HAVE_TESTRUNNER*/ | 
|---|
|  | 35 |  | 
|---|
|  | 36 | /********************************************** Test classes **************************************/ | 
|---|
|  | 37 |  | 
|---|
|  | 38 | // Registers the fixture into the 'registry' | 
|---|
|  | 39 | CPPUNIT_TEST_SUITE_REGISTRATION( ParameterStorageTest ); | 
|---|
|  | 40 |  | 
|---|
|  | 41 |  | 
|---|
|  | 42 | void ParameterStorageTest::setUp() | 
|---|
|  | 43 | {} | 
|---|
|  | 44 |  | 
|---|
|  | 45 |  | 
|---|
|  | 46 | void ParameterStorageTest::tearDown() | 
|---|
|  | 47 | {} | 
|---|
|  | 48 |  | 
|---|
|  | 49 | void ParameterStorageTest::instanceTest() | 
|---|
|  | 50 | { | 
|---|
|  | 51 | std::vector<int> ValidValues; | 
|---|
|  | 52 | for( int i=1; i<=4; ++i) | 
|---|
|  | 53 | ValidValues.push_back(i); | 
|---|
|  | 54 | range<double> ValidRange(1., 4.); | 
|---|
|  | 55 | Parameter *intParam = new DiscreteParameter<int>("intParam", ValidValues); | 
|---|
|  | 56 | Parameter *doubleParam = new ContinuousParameter<double>("doubleParam", ValidRange); | 
|---|
|  | 57 | // note: delete is done by registry in tearDown ... | 
|---|
|  | 58 |  | 
|---|
|  | 59 | // check that both are not present | 
|---|
|  | 60 | CPPUNIT_ASSERT_EQUAL(false, storage.isPresentByName("intParam")); | 
|---|
|  | 61 | CPPUNIT_ASSERT_EQUAL(false, storage.isPresentByName("doubleParam")); | 
|---|
|  | 62 | storage.registerInstance(intParam); | 
|---|
|  | 63 | storage.registerInstance(doubleParam); | 
|---|
|  | 64 | CPPUNIT_ASSERT_EQUAL(true, storage.isPresentByName("intParam")); | 
|---|
|  | 65 | CPPUNIT_ASSERT_EQUAL(true, storage.isPresentByName("doubleParam")); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | // retrieve instances and check address | 
|---|
|  | 68 | CPPUNIT_ASSERT_EQUAL(intParam, storage.getByName("intParam")); | 
|---|
|  | 69 | CPPUNIT_ASSERT_EQUAL(doubleParam, storage.getByName("doubleParam")); | 
|---|
|  | 70 | } | 
|---|