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 | * 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 "Parameters/Parameter.hpp"
|
---|
30 |
|
---|
31 | #ifdef HAVE_TESTRUNNER
|
---|
32 | #include "UnitTestMain.hpp"
|
---|
33 | #endif /*HAVE_TESTRUNNER*/
|
---|
34 |
|
---|
35 | /********************************************** Test classes **************************************/
|
---|
36 |
|
---|
37 | // Registers the fixture into the 'registry'
|
---|
38 | CPPUNIT_TEST_SUITE_REGISTRATION( ParameterStorageTest );
|
---|
39 |
|
---|
40 |
|
---|
41 | void ParameterStorageTest::setUp()
|
---|
42 | {}
|
---|
43 |
|
---|
44 |
|
---|
45 | void ParameterStorageTest::tearDown()
|
---|
46 | {}
|
---|
47 |
|
---|
48 | void ParameterStorageTest::instanceTest()
|
---|
49 | {
|
---|
50 | std::vector<int> ValidValues;
|
---|
51 | for( int i=1; i<=4; ++i)
|
---|
52 | ValidValues.push_back(i);
|
---|
53 | range<double> ValidRange(1., 4.);
|
---|
54 | ParameterAsString *intParam = new Parameter<int>("intParam", ValidValues);
|
---|
55 | ParameterAsString *doubleParam = new Parameter<double>("doubleParam", ValidRange);
|
---|
56 | // note: delete is done by registry in tearDown ...
|
---|
57 |
|
---|
58 | // check that both are not present
|
---|
59 | CPPUNIT_ASSERT_EQUAL(false, storage.isPresentByName("intParam"));
|
---|
60 | CPPUNIT_ASSERT_EQUAL(false, storage.isPresentByName("doubleParam"));
|
---|
61 | storage.registerInstance(intParam);
|
---|
62 | storage.registerInstance(doubleParam);
|
---|
63 | CPPUNIT_ASSERT_EQUAL(true, storage.isPresentByName("intParam"));
|
---|
64 | CPPUNIT_ASSERT_EQUAL(true, storage.isPresentByName("doubleParam"));
|
---|
65 |
|
---|
66 | // retrieve instances and check address
|
---|
67 | CPPUNIT_ASSERT_EQUAL(intParam, storage.getByName("intParam"));
|
---|
68 | CPPUNIT_ASSERT_EQUAL(doubleParam, storage.getByName("doubleParam"));
|
---|
69 | }
|
---|