Ignore:
Timestamp:
Mar 5, 2010, 1:45:35 PM (15 years ago)
Author:
Saskia Metzler <metzler@…>
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, 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:
9131f3
Parents:
7dc102 (diff), 31af19 (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:

solve merge conflict

Merge commit 'till/StructureRefactoring' into StateAndFormatParser

Conflicts:

molecuilder/src/unittests/Makefile.am

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/unittests/AtomDescriptorTest.cpp

    r7dc102 rcb2146  
    66 */
    77
    8 #include "DescriptorUnittest.hpp"
     8#include "AtomDescriptorTest.hpp"
    99
    1010#include <cppunit/CompilerOutputter.h>
     
    2525/********************************************** Test classes **************************************/
    2626// Registers the fixture into the 'registry'
    27 CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest );
     27CPPUNIT_TEST_SUITE_REGISTRATION( AtomDescriptorTest );
    2828
    2929// set up and tear down
    30 void DescriptorUnittest::setUp(){
     30void AtomDescriptorTest::setUp(){
    3131  World::get();
    3232  for(int i=0;i<ATOM_COUNT;++i){
    3333    atoms[i]= World::get()->createAtom();
    34     atomIds[i] = atoms[i]->getId();
     34    atomIds[i]= atoms[i]->getId();
    3535  }
    3636}
    37 void DescriptorUnittest::tearDown(){
     37
     38void AtomDescriptorTest::tearDown(){
    3839  World::destroy();
    3940}
    4041
    4142// some helper functions
    42 bool hasAll(std::vector<atom*> atoms,int ids[ATOM_COUNT], std::set<int> excluded = std::set<int>()){
     43static bool hasAllAtoms(std::vector<atom*> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){
    4344  for(int i=0;i<ATOM_COUNT;++i){
    44     int id = ids[i];
     45    atomId_t id = ids[i];
    4546    if(!excluded.count(id)){
    4647      std::vector<atom*>::iterator iter;
     
    5859}
    5960
    60 bool hasNoDuplicates(std::vector<atom*> atoms){
    61   std::set<int> found;
     61static bool hasNoDuplicateAtoms(std::vector<atom*> atoms){
     62  std::set<atomId_t> found;
    6263  std::vector<atom*>::iterator iter;
    6364  for(iter=atoms.begin();iter!=atoms.end();++iter){
     
    7172
    7273
    73 void DescriptorUnittest::AtomBaseSetsTest(){
     74void AtomDescriptorTest::AtomBaseSetsTest(){
    7475  std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
    75   CPPUNIT_ASSERT_EQUAL( true , hasAll(allAtoms,atomIds));
    76   CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(allAtoms));
     76  CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(allAtoms,atomIds));
     77  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(allAtoms));
    7778
    7879  std::vector<atom*> noAtoms = World::get()->getAllAtoms(NoAtoms());
    7980  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
    8081}
    81 void DescriptorUnittest::AtomIdTest(){
     82void AtomDescriptorTest::AtomIdTest(){
    8283  // test Atoms from boundaries and middle of the set
    8384  atom* testAtom;
     
    9394
    9495  // find some ID that has not been created
    95   int outsideId =-1;
     96  atomId_t outsideId=0;
    9697  bool res = false;
    97   while(!res) {
    98     ++outsideId;
     98  for(outsideId=0;!res;++outsideId) {
    9999    res = true;
    100100    for(int i = 0; i < ATOM_COUNT; ++i){
     
    106106  CPPUNIT_ASSERT(!testAtom);
    107107}
    108 void DescriptorUnittest::AtomCalcTest(){
     108void AtomDescriptorTest::AtomCalcTest(){
    109109  // test some elementary set operations
    110110  {
    111111    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()||NoAtoms());
    112     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    113     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
     112    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
     113    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
    114114  }
    115115
    116116  {
    117117    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||AllAtoms());
    118     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    119     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
     118    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
     119    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
    120120  }
    121121
     
    137137  {
    138138    std::vector<atom*> testAtoms = World::get()->getAllAtoms(!NoAtoms());
    139     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds));
    140     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
     139    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds));
     140    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
    141141  }
    142142
     
    144144  {
    145145    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(atomIds[ATOM_COUNT/2])));
    146     std::set<int> excluded;
     146    std::set<atomId_t> excluded;
    147147    excluded.insert(atomIds[ATOM_COUNT/2]);
    148     CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,atomIds,excluded));
    149     CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
     148    CPPUNIT_ASSERT_EQUAL( true , hasAllAtoms(testAtoms,atomIds,excluded));
     149    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicateAtoms(testAtoms));
    150150    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
    151151  }
Note: See TracChangeset for help on using the changeset viewer.