Changeset ead4e6 for src/unittests
- Timestamp:
- Mar 12, 2010, 1:16:01 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, 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:
- 745a85
- Parents:
- c3dbe0
- Location:
- src/unittests
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/AtomDescriptorTest.hpp
rc3dbe0 read4e6 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #include " defs.hpp"13 #include "types.hpp" 14 14 15 15 #define ATOM_COUNT (10) -
src/unittests/CacheableTest.cpp
rc3dbe0 read4e6 27 27 class threeNumbers : public Observable { 28 28 public: 29 bool hasRecalced;30 29 int x; 31 30 int y; 32 31 int z; 32 Cacheable<int> sum; 33 bool hasRecalced; 33 34 34 35 void setX(int _x){ … … 54 55 55 56 threeNumbers(int _x,int _y, int _z) : 57 x(_x),y(_y),z(_z), 56 58 sum(this,boost::bind(&threeNumbers::calcSum,this)), 57 x(_x),y(_y),z(_z),58 59 hasRecalced(false) 59 60 {} 60 61 Cacheable<int> sum;62 61 }; 63 62 -
src/unittests/MoleculeDescriptorTest.hpp
rc3dbe0 read4e6 11 11 #include <cppunit/extensions/HelperMacros.h> 12 12 13 #include " defs.hpp"13 #include "types.hpp" 14 14 15 15 #define MOLECULE_COUNT (10) -
src/unittests/analysisbondsunittest.cpp
rc3dbe0 read4e6 53 53 strcpy(hydrogen->symbol, "H"); 54 54 carbon = new element; 55 carbon->Z = 1;55 carbon->Z = 2; 56 56 carbon->Valence = 4; 57 57 carbon->NoValenceOrbitals = 4; -
src/unittests/atomsCalculationTest.cpp
rc3dbe0 read4e6 31 31 CPPUNIT_TEST_SUITE_REGISTRATION( atomsCalculationTest ); 32 32 33 // some stubs34 class AtomStub : public atom {35 public:36 AtomStub(atomId_t _id) :37 atom(),38 id(_id),39 manipulated(false)40 {}41 42 virtual atomId_t getId(){43 return id;44 }45 46 virtual void doSomething(){47 manipulated = true;48 }49 50 bool manipulated;51 private:52 atomId_t id;53 };54 55 33 // set up and tear down 56 34 void atomsCalculationTest::setUp(){ 57 35 World::getInstance(); 58 36 for(int i=0;i<ATOM_COUNT;++i){ 59 atoms[i]= new AtomStub(i);60 World::getInstance().registerAtom(atoms[i]);37 atoms[i]= World::getInstance().createAtom(); 38 atomIds[i]= atoms[i]->getId(); 61 39 } 62 40 } … … 67 45 68 46 // some helper functions 69 static bool hasAll(std::vector<int> ids,int min, int max, std::set<int> excluded = std::set<int>()){ 70 for(int i=min;i<max;++i){ 71 if(!excluded.count(i)){ 72 std::vector<int>::iterator iter; 47 static bool hasAllIds(std::vector<atomId_t> atoms,atomId_t ids[ATOM_COUNT], std::set<atomId_t> excluded = std::set<atomId_t>()){ 48 for(int i=0;i<ATOM_COUNT;++i){ 49 atomId_t id = ids[i]; 50 if(!excluded.count(id)){ 51 std::vector<atomId_t>::iterator iter; 73 52 bool res=false; 74 for(iter= ids.begin();iter!=ids.end();++iter){75 res |= (*iter) == i ;53 for(iter=atoms.begin();iter!=atoms.end();++iter){ 54 res |= (*iter) == id; 76 55 } 77 56 if(!res) { 78 cout << "Atom " << i << " missing in returned list" << endl;57 cout << "Atom " << id << " missing in returned list" << endl; 79 58 return false; 80 59 } … … 84 63 } 85 64 86 static bool hasNoDuplicates(std::vector< int> ids){87 std::set< int> found;88 std::vector< int>::iterator iter;65 static bool hasNoDuplicates(std::vector<atomId_t> ids){ 66 std::set<atomId_t> found; 67 std::vector<atomId_t>::iterator iter; 89 68 for(iter=ids.begin();iter!=ids.end();++iter){ 90 69 int id = (*iter); … … 97 76 98 77 void atomsCalculationTest::testCalculateSimple(){ 99 AtomsCalculation< int> *calc = World::getInstance().calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms());100 std::vector< int> allIds = (*calc)();101 CPPUNIT_ASSERT(hasAll (allIds,0,ATOM_COUNT));78 AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms()); 79 std::vector<atomId_t> allIds = (*calc)(); 80 CPPUNIT_ASSERT(hasAllIds(allIds,atomIds)); 102 81 CPPUNIT_ASSERT(hasNoDuplicates(allIds)); 103 82 } 104 83 105 84 void atomsCalculationTest::testCalculateExcluded(){ 106 int excluded = ATOM_COUNT/2;107 AtomsCalculation< int> *calc = World::getInstance().calcOnAtoms<int>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded));108 std::vector< int> allIds = (*calc)();109 std::set< int> excluded_set;85 atomId_t excluded = atomIds[ATOM_COUNT/2]; 86 AtomsCalculation<atomId_t> *calc = World::getInstance().calcOnAtoms<atomId_t>(boost::bind(&atom::getId,_1),"FOO",AllAtoms() && !AtomById(excluded)); 87 std::vector<atomId_t> allIds = (*calc)(); 88 std::set<atomId_t> excluded_set; 110 89 excluded_set.insert(excluded); 111 CPPUNIT_ASSERT(hasAll (allIds,0,ATOM_COUNT,excluded_set));90 CPPUNIT_ASSERT(hasAllIds(allIds,atomIds,excluded_set)); 112 91 CPPUNIT_ASSERT(hasNoDuplicates(allIds)); 113 92 CPPUNIT_ASSERT_EQUAL((size_t)(ATOM_COUNT-1),allIds.size()); -
src/unittests/atomsCalculationTest.hpp
rc3dbe0 read4e6 12 12 13 13 #define ATOM_COUNT (10) 14 15 #include "types.hpp" 14 16 15 17 class atom; … … 31 33 private: 32 34 atom *atoms [ATOM_COUNT]; 33 int atomIds [ATOM_COUNT];35 atomId_t atomIds [ATOM_COUNT]; 34 36 }; 35 37 -
src/unittests/bondgraphunittest.cpp
rc3dbe0 read4e6 51 51 strcpy(hydrogen->symbol, "H"); 52 52 carbon = new element; 53 carbon->Z = 1;53 carbon->Z = 2; 54 54 strcpy(carbon->name, "carbon"); 55 55 strcpy(carbon->symbol, "C");
Note:
See TracChangeset
for help on using the changeset viewer.