Changeset a881f5 for src/unittests


Ignore:
Timestamp:
Aug 5, 2010, 8:06:42 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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.
Message:

Merge branch 'StructureRefactoring' into stable

Conflicts:

src/Actions/AnalysisAction/PairCorrelationAction.hpp
src/Actions/AnalysisAction/SurfaceCorrelationAction.hpp

  • due to different ordering of vector, string includes
Location:
src/unittests
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/ActionSequenceTest.cpp

    r5fbaeb ra881f5  
    1717#include "Actions/ActionRegistry.hpp"
    1818
     19#include "DummyUI.hpp"
     20
    1921#ifdef HAVE_TESTRUNNER
    2022#include "UnitTestMain.hpp"
     
    3335  virtual ~canUndoActionStub(){}
    3436
    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;
    3740  }
    3841
     
    6063  virtual ~cannotUndoActionStub(){}
    6164
    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;
    6468  }
    6569
     
    9094  virtual ~wasCalledActionStub(){}
    9195
    92   virtual Dialog* createDialog(){
    93     return NULL;
     96  virtual Dialog* fillDialog(Dialog *dialog){
     97    return dialog;
    9498  }
    9599  virtual Action::state_ptr performCall(){
     
    119123
    120124void ActionSequenceTest::setUp(){
     125  static bool hasDescriptor = false;
    121126  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");
    122133  // create some necessary stubs used in this test
    123134  positive1 = new canUndoActionStub();
     
    146157  ActionHistory::purgeInstance();
    147158  ActionRegistry::purgeInstance();
     159  UIFactory::purgeInstance();
    148160}
    149161
     
    231243
    232244  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
    233   CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
     245  CPPUNIT_ASSERT_EQUAL(true,wasCalled2->wasCalled());
    234246
    235247  ActionHistory::getInstance().undoLast();
    236248
    237249  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
    238   CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
    239 
    240 }
    241 
    242 
     250  CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
     251
     252}
     253
     254
  • src/unittests/FormulaUnittest.cpp

    r5fbaeb ra881f5  
    185185  }
    186186  {
     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  {
    187238    CPPUNIT_ASSERT_THROW(Formula formula("74107"),ParseError);
    188239    CPPUNIT_ASSERT_THROW(Formula formula("  "),ParseError);
     
    192243    CPPUNIT_ASSERT_THROW(Formula formula("1NaCl"),ParseError);
    193244    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);
    194255  }
    195256
  • src/unittests/Makefile.am

    r5fbaeb ra881f5  
    77AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
    88
    9 MENUTESTS = \
    10   ActionSequenceTest
    11 
    129TESTS = \
     10  ActionSequenceTest \
    1311  ActOnAllUnitTest \
    1412  AnalysisBondsUnitTests \
     
    1917  AtomDescriptorTest \
    2018  BondGraphUnitTest \
     19  BoxUnittest \
    2120  CacheableTest \
    2221  CountBondsUnitTest \
     
    4443  Tesselation_BoundaryTriangleUnitTest \
    4544  Tesselation_InOutsideUnitTest \
    46   VectorUnitTest \
    47   ${MENUTESTS}
     45  VectorUnitTest
    4846 
    4947 
     
    5149noinst_PROGRAMS = $(TESTS) TestRunner
    5250
    53 GSLLIBS = ../libgslwrapper.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
     51GSLLIBS = ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB}
    5452ALLLIBS = ../libmolecuilder.a ${GSLLIBS}
    5553PARSERLIBS = ../libparser.a ${ALLLIBS}
     54UILIBS = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ${ALLLIBS} ${BOOST_PROGRAM_OPTIONS_LIB}
    5655
    5756TESTSOURCES = \
     
    6564  atomsCalculationTest.cpp \
    6665  bondgraphunittest.cpp \
     66  BoxUnittest.cpp \
    6767  CacheableTest.cpp \
    6868  CountBondsUnitTest.cpp \
     
    102102  atomsCalculationTest.hpp \
    103103  bondgraphunittest.hpp \
     104  BoxUnittest.hpp \
    104105  CacheableTest.hpp \
    105106  CountBondsUnitTest.hpp \
     
    128129 
    129130
    130 ActionSequenceTest_SOURCES = UnitTestMain.cpp ../../../TestRunnerClient.hpp ActionSequenceTest.cpp ActionSequenceTest.hpp
    131 ActionSequenceTest_LDADD = ${ALLLIBS}
     131ActionSequenceTest_SOURCES = UnitTestMain.cpp ActionSequenceTest.cpp ActionSequenceTest.hpp $(srcdir)/../version.c
     132ActionSequenceTest_LDADD = ${UILIBS}
    132133
    133134ActOnAllUnitTest_SOURCES = UnitTestMain.cpp ../test/ActOnAllTest.hpp ActOnAllUnitTest.cpp ActOnAllUnitTest.hpp
     
    155156BondGraphUnitTest_LDADD = ${ALLLIBS}
    156157
     158BoxUnittest_SOURCES = UnitTestMain.cpp BoxUnittest.cpp BoxUnittest.hpp
     159BoxUnittest_LDADD = ${ALLLIBS}
     160
    157161CacheableTest_SOURCES = UnitTestMain.cpp CacheableTest.cpp CacheableTest.hpp
    158162CacheableTest_LDADD = ${ALLLIBS}
     
    191195LogUnitTest_LDADD = ${ALLLIBS}
    192196
    193 manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp
    194 manipulateAtomsTest_LDADD = ${ALLLIBS}
     197manipulateAtomsTest_SOURCES = UnitTestMain.cpp manipulateAtomsTest.cpp manipulateAtomsTest.hpp $(srcdir)/../version.c
     198manipulateAtomsTest_LDADD = ${UILIBS}
    195199
    196200MatrixUnittest_SOURCES = UnitTestMain.cpp MatrixUnittest.cpp MatrixUnittest.hpp
     
    230234Tesselation_InOutsideUnitTest_LDADD = ${ALLLIBS}
    231235
    232 TestRunner_SOURCES = TestRunnerMain.cpp $(TESTSOURCES) $(TESTHEADERS)
    233 TestRunner_LDADD = ${ALLLIBS}
     236TestRunner_SOURCES = TestRunnerMain.cpp $(srcdir)/../version.c $(TESTSOURCES) $(TESTHEADERS)
     237TestRunner_LDADD = ../UIElements/libMolecuilderUI.a ../Actions/libMolecuilderActions.a ../libmolecuilder.a ../libparser.a ../libgslwrapper.a ../libmolecuilderbase.a $(BOOST_LIB) ${BOOST_THREAD_LIB} ${BOOST_PROGRAM_OPTIONS_LIB}
    234238
    235239VectorUnitTest_SOURCES = UnitTestMain.cpp vectorunittest.cpp vectorunittest.hpp
  • src/unittests/manipulateAtomsTest.cpp

    r5fbaeb ra881f5  
    2222#include "World.hpp"
    2323#include "atom.hpp"
     24
     25#include "DummyUI.hpp"
    2426
    2527#ifdef HAVE_TESTRUNNER
     
    7274// set up and tear down
    7375void manipulateAtomsTest::setUp(){
     76  static bool hasDescriptor = false;
    7477  ActionHistory::init();
    7578  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");
    7685  for(int i=0;i<ATOM_COUNT;++i){
    7786    atoms[i]= new AtomStub(i);
     
    8392  ActionRegistry::purgeInstance();
    8493  ActionHistory::purgeInstance();
     94  UIFactory::purgeInstance();
    8595}
    8696
Note: See TracChangeset for help on using the changeset viewer.