| [f649de] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [94d5ac6] | 5 |  * 
 | 
|---|
 | 6 |  *
 | 
|---|
 | 7 |  *   This file is part of MoleCuilder.
 | 
|---|
 | 8 |  *
 | 
|---|
 | 9 |  *    MoleCuilder is free software: you can redistribute it and/or modify
 | 
|---|
 | 10 |  *    it under the terms of the GNU General Public License as published by
 | 
|---|
 | 11 |  *    the Free Software Foundation, either version 2 of the License, or
 | 
|---|
 | 12 |  *    (at your option) any later version.
 | 
|---|
 | 13 |  *
 | 
|---|
 | 14 |  *    MoleCuilder is distributed in the hope that it will be useful,
 | 
|---|
 | 15 |  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
 | 16 |  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
 | 17 |  *    GNU General Public License for more details.
 | 
|---|
 | 18 |  *
 | 
|---|
 | 19 |  *    You should have received a copy of the GNU General Public License
 | 
|---|
 | 20 |  *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
 | 
|---|
| [f649de] | 21 |  */
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | /*
 | 
|---|
 | 24 |  * WorldTimeUnitTest.cpp
 | 
|---|
 | 25 |  *
 | 
|---|
 | 26 |  *  Created on: Oct 29, 2009
 | 
|---|
 | 27 |  *      Author: heber
 | 
|---|
 | 28 |  */
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | // include config.h
 | 
|---|
 | 31 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 32 | #include <config.h>
 | 
|---|
 | 33 | #endif
 | 
|---|
 | 34 | 
 | 
|---|
 | 35 | using namespace std;
 | 
|---|
 | 36 | 
 | 
|---|
 | 37 | #include <cppunit/CompilerOutputter.h>
 | 
|---|
 | 38 | #include <cppunit/extensions/TestFactoryRegistry.h>
 | 
|---|
 | 39 | #include <cppunit/ui/text/TestRunner.h>
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 | #include <iostream>
 | 
|---|
 | 42 | #include <stdio.h>
 | 
|---|
 | 43 | #include <cstring>
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 | #include "CodePatterns/Assert.hpp"
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | #include "WorldTime.hpp"
 | 
|---|
 | 48 | 
 | 
|---|
 | 49 | #include "WorldTimeUnitTest.hpp"
 | 
|---|
 | 50 | 
 | 
|---|
 | 51 | #ifdef HAVE_TESTRUNNER
 | 
|---|
 | 52 | #include "UnitTestMain.hpp"
 | 
|---|
 | 53 | #endif /*HAVE_TESTRUNNER*/
 | 
|---|
 | 54 | 
 | 
|---|
 | 55 | /********************************************** Test classes **************************************/
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | //!< tremolo's standard time step is 1.0180505e-14 s which is ... in atomictime
 | 
|---|
 | 58 | const double TremolosTIME = 420.87606;
 | 
|---|
 | 59 | 
 | 
|---|
 | 60 | // Registers the fixture into the 'registry'
 | 
|---|
 | 61 | CPPUNIT_TEST_SUITE_REGISTRATION( WorldTimeTest );
 | 
|---|
 | 62 | 
 | 
|---|
 | 63 | 
 | 
|---|
 | 64 | void WorldTimeTest::setUp()
 | 
|---|
 | 65 | {
 | 
|---|
 | 66 |   Time = WorldTime::getPointer();
 | 
|---|
 | 67 | };
 | 
|---|
 | 68 | 
 | 
|---|
 | 69 | 
 | 
|---|
 | 70 | void WorldTimeTest::tearDown()
 | 
|---|
 | 71 | {
 | 
|---|
 | 72 |   WorldTime::purgeInstance();
 | 
|---|
 | 73 | };
 | 
|---|
 | 74 | 
 | 
|---|
 | 75 | /** Tests whether CurrentTime is accessible
 | 
|---|
 | 76 |  */
 | 
|---|
 | 77 | void WorldTimeTest::CurrentTimeTest()
 | 
|---|
 | 78 | {
 | 
|---|
 | 79 |   // check default is 0
 | 
|---|
| [6bb605] | 80 |   CPPUNIT_ASSERT_EQUAL ((unsigned int)0, Time->getTime() );
 | 
|---|
| [f649de] | 81 | 
 | 
|---|
 | 82 |   // set and check
 | 
|---|
 | 83 |   Time->setTime(10);
 | 
|---|
| [6bb605] | 84 |   CPPUNIT_ASSERT_EQUAL ((unsigned int)10, Time->getTime() );
 | 
|---|
| [f649de] | 85 | };
 | 
|---|
 | 86 | 
 | 
|---|
 | 87 | /** Tests whether CurrentTime is accessible
 | 
|---|
 | 88 |  */
 | 
|---|
 | 89 | void WorldTimeTest::StepWidthTest()
 | 
|---|
 | 90 | {
 | 
|---|
 | 91 |   // check default is 0
 | 
|---|
 | 92 |   CPPUNIT_ASSERT_EQUAL (0., Time->getStepWidth() );
 | 
|---|
 | 93 | 
 | 
|---|
 | 94 |   // set and check
 | 
|---|
 | 95 |   Time->setStepWidth(TremolosTIME);
 | 
|---|
 | 96 |   CPPUNIT_ASSERT_EQUAL (TremolosTIME, Time->getStepWidth() );
 | 
|---|
 | 97 | };
 | 
|---|
 | 98 | 
 | 
|---|