Changeset a881f5 for src/unittests
- Timestamp:
- Aug 5, 2010, 8:06:42 PM (16 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, Candidate_v1.7.0, Candidate_v1.7.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 6d587e
- Parents:
- 5fbaeb (diff), f761c4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src/unittests
- Files:
-
- 3 added
- 4 edited
-
ActionSequenceTest.cpp (modified) (7 diffs)
-
BoxUnittest.cpp (added)
-
BoxUnittest.hpp (added)
-
DummyUI.hpp (added)
-
FormulaUnittest.cpp (modified) (2 diffs)
-
Makefile.am (modified) (10 diffs)
-
manipulateAtomsTest.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/ActionSequenceTest.cpp
r5fbaeb ra881f5 17 17 #include "Actions/ActionRegistry.hpp" 18 18 19 #include "DummyUI.hpp" 20 19 21 #ifdef HAVE_TESTRUNNER 20 22 #include "UnitTestMain.hpp" … … 33 35 virtual ~canUndoActionStub(){} 34 36 35 virtual Dialog* createDialog(){ 36 return NULL; 37 virtual Dialog* fillDialog(Dialog *dialog){ 38 ASSERT(dialog,"No Dialog given when filling action dialog"); 39 return dialog; 37 40 } 38 41 … … 60 63 virtual ~cannotUndoActionStub(){} 61 64 62 virtual Dialog* createDialog(){ 63 return NULL; 65 virtual Dialog* fillDialog(Dialog *dialog){ 66 ASSERT(dialog,"No Dialog given when filling action dialog"); 67 return dialog; 64 68 } 65 69 … … 90 94 virtual ~wasCalledActionStub(){} 91 95 92 virtual Dialog* createDialog(){93 return NULL;96 virtual Dialog* fillDialog(Dialog *dialog){ 97 return dialog; 94 98 } 95 99 virtual Action::state_ptr performCall(){ … … 119 123 120 124 void ActionSequenceTest::setUp(){ 125 static bool hasDescriptor = false; 121 126 ActionHistory::init(); 127 // TODO: find a way to really reset the factory to a clean state in tear-down 128 if(!hasDescriptor){ 129 UIFactory::registerFactory(new DummyUIFactory::description()); 130 hasDescriptor = true; 131 } 132 UIFactory::makeUserInterface("Dummy"); 122 133 // create some necessary stubs used in this test 123 134 positive1 = new canUndoActionStub(); … … 146 157 ActionHistory::purgeInstance(); 147 158 ActionRegistry::purgeInstance(); 159 UIFactory::purgeInstance(); 148 160 } 149 161 … … 231 243 232 244 CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled()); 233 CPPUNIT_ASSERT_EQUAL(true,wasCalled 1->wasCalled());245 CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled()); 234 246 235 247 ActionHistory::getInstance().undoLast(); 236 248 237 249 CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled()); 238 CPPUNIT_ASSERT_EQUAL(false,wasCalled 1->wasCalled());239 240 } 241 242 250 CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled()); 251 252 } 253 254 -
src/unittests/FormulaUnittest.cpp
r5fbaeb ra881f5 185 185 } 186 186 { 187 Formula formula("CH2(COOH)2"); 188 CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)4); 189 CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)4); 190 CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)3); 191 CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0); 192 CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0); 193 } 194 { 195 Formula formula("K4[Fe(CN)6]"); 196 CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0); 197 CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0); 198 CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)6); 199 CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0); 200 CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0); 201 CPPUNIT_ASSERT_EQUAL(formula["K"],(unsigned int)4); 202 CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)1); 203 CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)6); 204 } 205 { 206 Formula formula("[CrCl3(H2O)3]"); 207 CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)6); 208 CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)3); 209 CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)0); 210 CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0); 211 CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0); 212 CPPUNIT_ASSERT_EQUAL(formula["Cr"],(unsigned int)1); 213 CPPUNIT_ASSERT_EQUAL(formula["Cl"],(unsigned int)3); 214 } 215 { 216 Formula formula("Mg3[Fe(CN)6]2"); 217 CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)0); 218 CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)0); 219 CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)12); 220 CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)0); 221 CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0); 222 CPPUNIT_ASSERT_EQUAL(formula["Mg"],(unsigned int)3); 223 CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)2); 224 CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)12); 225 } 226 { 227 Formula formula("Na[Fe((HO2CCH2)2NCH2CH2N(CH2CO2H)2)]"); 228 CPPUNIT_ASSERT_EQUAL(formula["H"],(unsigned int)16); 229 CPPUNIT_ASSERT_EQUAL(formula["O"],(unsigned int)8); 230 CPPUNIT_ASSERT_EQUAL(formula["C"],(unsigned int)10); 231 CPPUNIT_ASSERT_EQUAL(formula["Na"],(unsigned int)1); 232 CPPUNIT_ASSERT_EQUAL(formula["He"],(unsigned int)0); 233 CPPUNIT_ASSERT_EQUAL(formula["Mg"],(unsigned int)0); 234 CPPUNIT_ASSERT_EQUAL(formula["Fe"],(unsigned int)1); 235 CPPUNIT_ASSERT_EQUAL(formula["N"],(unsigned int)2); 236 } 237 { 187 238 CPPUNIT_ASSERT_THROW(Formula formula("74107"),ParseError); 188 239 CPPUNIT_ASSERT_THROW(Formula formula(" "),ParseError); … … 192 243 CPPUNIT_ASSERT_THROW(Formula formula("1NaCl"),ParseError); 193 244 CPPUNIT_ASSERT_THROW(Formula formula("Mag"),ParseError); 245 CPPUNIT_ASSERT_THROW(Formula formula("AgCl)"),ParseError); 246 CPPUNIT_ASSERT_THROW(Formula formula("(Na"),ParseError); 247 CPPUNIT_ASSERT_THROW(Formula formula("(Mag)"),ParseError); 248 CPPUNIT_ASSERT_THROW(Formula formula("MgCl2)"),ParseError); 249 CPPUNIT_ASSERT_THROW(Formula formula("((MgCl2)"),ParseError); 250 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2))"),ParseError); 251 CPPUNIT_ASSERT_THROW(Formula formula("(MgCl2]"),ParseError); 252 CPPUNIT_ASSERT_THROW(Formula formula("[MgCl2)"),ParseError); 253 CPPUNIT_ASSERT_THROW(Formula formula("N(aCl"),ParseError); 254 CPPUNIT_ASSERT_THROW(Formula formula("Na()Cl"),ParseError); 194 255 } 195 256 -
src/unittests/Makefile.am
r5fbaeb ra881f5 7 7 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 8 8 9 MENUTESTS = \10 ActionSequenceTest11 12 9 TESTS = \ 10 ActionSequenceTest \ 13 11 ActOnAllUnitTest \ 14 12 AnalysisBondsUnitTests \ … … 19 17 AtomDescriptorTest \ 20 18 BondGraphUnitTest \ 19 BoxUnittest \ 21 20 CacheableTest \ 22 21 CountBondsUnitTest \ … … 44 43 Tesselation_BoundaryTriangleUnitTest \ 45 44 Tesselation_InOutsideUnitTest \ 46 VectorUnitTest \ 47 ${MENUTESTS} 45 VectorUnitTest 48 46 49 47 … … 51 49 noinst_PROGRAMS = $(TESTS) TestRunner 52 50 53 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}51 GSLLIBS = ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} 54 52 ALLLIBS = ../libmolecuilder.a ${GSLLIBS} 55 53 PARSERLIBS = ../libparser.a ${ALLLIBS} 54 UILIBS = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ${ALLLIBS} ${BOOST_PROGRAM_OPTIONS_LIB} 56 55 57 56 TESTSOURCES = \ … … 65 64 atomsCalculationTest.cpp \ 66 65 bondgraphunittest.cpp \ 66 BoxUnittest.cpp \ 67 67 CacheableTest.cpp \ 68 68 CountBondsUnitTest.cpp \ … … 102 102 atomsCalculationTest.hpp \ 103 103 bondgraphunittest.hpp \ 104 BoxUnittest.hpp \ 104 105 CacheableTest.hpp \ 105 106 CountBondsUnitTest.hpp \ … … 128 129 129 130 130 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp131 ActionSequenceTest_LDADD = ${ ALLLIBS}131 ActionSequenceTest_SOURCES = UnitTestMain.cpp ActionSequenceTest.cpp ActionSequenceTest.hpp $(srcdir)/../version.c 132 ActionSequenceTest_LDADD = ${UILIBS} 132 133 133 134 ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp … … 155 156 BondGraphUnitTest_LDADD = ${ALLLIBS} 156 157 158 BoxUnittest_SOURCES = UnitTestMain.cpp BoxUnittest.cpp BoxUnittest.hpp 159 BoxUnittest_LDADD = ${ALLLIBS} 160 157 161 CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp 158 162 CacheableTest_LDADD = ${ALLLIBS} … … 191 195 LogUnitTest_LDADD = ${ALLLIBS} 192 196 193 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp 194 manipulateAtomsTest_LDADD = ${ ALLLIBS}197 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp $(srcdir)/../version.c 198 manipulateAtomsTest_LDADD = ${UILIBS} 195 199 196 200 MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp … … 230 234 Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS} 231 235 232 TestRunner_SOURCES = TestRunnerMain.cpp $( TESTSOURCES) $(TESTHEADERS)233 TestRunner_LDADD = ${ALLLIBS}236 TestRunner_SOURCES = TestRunnerMain.cpp $(srcdir)/../version.c $(TESTSOURCES) $(TESTHEADERS) 237 TestRunner_LDADD = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ../libmolecuilder.a ../libparser.a ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB} 234 238 235 239 VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp -
src/unittests/manipulateAtomsTest.cpp
r5fbaeb ra881f5 22 22 #include "World.hpp" 23 23 #include "atom.hpp" 24 25 #include "DummyUI.hpp" 24 26 25 27 #ifdef HAVE_TESTRUNNER … … 72 74 // set up and tear down 73 75 void manipulateAtomsTest::setUp(){ 76 static bool hasDescriptor = false; 74 77 ActionHistory::init(); 75 78 World::getInstance(); 79 // TODO: find a way to really reset the factory to a clean state in tear-down 80 if(!hasDescriptor){ 81 UIFactory::registerFactory(new DummyUIFactory::description()); 82 hasDescriptor = true; 83 } 84 UIFactory::makeUserInterface("Dummy"); 76 85 for(int i=0;i<ATOM_COUNT;++i){ 77 86 atoms[i]= new AtomStub(i); … … 83 92 ActionRegistry::purgeInstance(); 84 93 ActionHistory::purgeInstance(); 94 UIFactory::purgeInstance(); 85 95 } 86 96
Note:
See TracChangeset
for help on using the changeset viewer.
