Changeset d96277
- Timestamp:
- Oct 29, 2009, 10:09:05 AM (15 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:
- 8c5327
- Parents:
- c0f6c6
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/stackclass.hpp
rc0f6c6 rd96277 33 33 bool RemoveItem(T ptr); 34 34 void ClearStack(); 35 bool IsEmpty(); 36 bool IsFull(); 37 int ItemCount(); 38 void Output(ofstream *out) const; 39 void TestImplementation(ofstream *out, T test); 35 bool IsEmpty() const; 36 bool IsFull() const; 37 int ItemCount() const; 38 void Output(ofstream * const out) const; 40 39 41 40 private: … … 49 48 /** Constructor of class StackClass. 50 49 */ 51 template <typename T> StackClass<T>::StackClass(int dimension) 52 { 53 CurrentLastEntry = 0; 54 CurrentFirstEntry = 0; 55 NextFreeField = 0; 56 EntryCount = dimension; 50 template <typename T> StackClass<T>::StackClass(int dimension) : EntryCount(dimension), CurrentLastEntry(0), CurrentFirstEntry(0), NextFreeField(0) 51 { 57 52 StackList = Malloc<T>(EntryCount, "StackClass::StackClass: **StackList"); 58 53 }; … … 165 160 }; 166 161 167 /** Test the functionality of the stack.168 * \param *out ofstream for debugging169 * \param *test one item to put on stack170 * \return true - all tests worked correctly171 */172 template <typename T> void StackClass<T>::TestImplementation(ofstream *out, T test)173 {174 T Walker = test;175 *out << Verbose(1) << "Testing the snake stack..." << endl;176 for (int i=0;i<EntryCount;i++) {177 *out << Verbose(2) << "Filling " << i << "th element of stack." << endl;178 Push(Walker);179 Walker=Walker->next;180 }181 *out << endl;182 Output(out);183 if (IsFull())184 *out << "Stack is full as supposed to be!" << endl;185 else186 *out << "ERROR: Stack is not as full as supposed to be!" << endl;187 //if (StackList[(EntryCount+1)/2] != NULL) {188 *out << "Removing element in the middle ..." << endl;189 RemoveItem(StackList[(EntryCount+1)/2]);190 Output(out);191 //}192 //if (StackList[CurrentFirstEntry] != NULL) {193 *out << "Removing first element ..." << endl;194 RemoveItem(StackList[CurrentFirstEntry]);195 Output(out);196 //}197 //if (StackList[CurrentLastEntry] != NULL) {198 *out << "Removing last element ..." << endl;199 RemoveItem(StackList[CurrentLastEntry]);200 Output(out);201 //}202 *out << "Clearing stack ... " << endl;203 ClearStack();204 Output(out);205 if (IsEmpty())206 *out << "Stack is empty as supposed to be!" << endl;207 else208 *out << "ERROR: Stack is not as empty as supposed to be!" << endl;209 *out << "done." << endl;210 };211 162 212 163 /** Puts contents of stack into ofstream \a *out. 213 164 * \param *out ofstream for output 214 165 */ 215 template <typename T> void StackClass<T>::Output(ofstream * out) const166 template <typename T> void StackClass<T>::Output(ofstream * const out) const 216 167 { 217 168 *out << "Contents of Stack: "; … … 234 185 * \return true - empty, false - not 235 186 */ 236 template <typename T> bool StackClass<T>::IsEmpty() 187 template <typename T> bool StackClass<T>::IsEmpty() const 237 188 { 238 189 return((NextFreeField == CurrentFirstEntry) && (CurrentLastEntry == CurrentFirstEntry)); … … 244 195 * \return true - full, false - not 245 196 */ 246 template <typename T> bool StackClass<T>::IsFull() 197 template <typename T> bool StackClass<T>::IsFull() const 247 198 { 248 199 return((NextFreeField == CurrentFirstEntry) && (CurrentLastEntry != CurrentFirstEntry)); … … 254 205 * \warning will never return correct item count if stack is full, i.e. count would be StackClass::EntryCount. 255 206 */ 256 template <typename T> int StackClass<T>::ItemCount() 207 template <typename T> int StackClass<T>::ItemCount() const 257 208 { 258 209 //cout << "Stack: CurrentLastEntry " << CurrentLastEntry<< "\tCurrentFirstEntry " << CurrentFirstEntry << "\tEntryCount " << EntryCount << "." << endl; -
src/unittests/Makefile.am
rc0f6c6 rd96277 4 4 AM_CXXFLAGS = $(CPPUNIT_CFLAGS) 5 5 6 TESTS = ActOnAllUnitTest AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest ListOfBondsUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest VectorUnitTest6 TESTS = ActOnAllUnitTest AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest ListOfBondsUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest 7 7 check_PROGRAMS = $(TESTS) 8 8 noinst_PROGRAMS = $(TESTS) … … 23 23 ListOfBondsUnitTest_LDADD = ../libmolecuilder.a 24 24 25 VectorUnitTest_SOURCES = defs.hpp helpers.hpp leastsquaremin.hpp memoryallocator.hpp memoryusageobserver.hpp vectorunittest.cpp vectorunittest.hpp vector.hpp verbose.hpp26 VectorUnitTest_LDADD = ../libmolecuilder.a27 28 25 MemoryAllocatorUnitTest_SOURCES = defs.hpp helpers.hpp memoryallocatorunittest.cpp memoryallocatorunittest.hpp memoryallocator.hpp memoryusageobserver.hpp verbose.hpp 29 26 MemoryAllocatorUnitTest_LDADD = ../libmolecuilder.a … … 32 29 MemoryUsageObserverUnitTest_LDADD = ../libmolecuilder.a 33 30 31 StackClassUnitTest_SOURCES = stackclass.hpp stackclassunittest.cpp stackclassunittest.hpp 32 StackClassUnitTest_LDADD = ../libmolecuilder.a 33 34 VectorUnitTest_SOURCES = defs.hpp helpers.hpp leastsquaremin.hpp memoryallocator.hpp memoryusageobserver.hpp vectorunittest.cpp vectorunittest.hpp vector.hpp verbose.hpp 35 VectorUnitTest_LDADD = ../libmolecuilder.a 36 37 34 38 #AUTOMAKE_OPTIONS = parallel-tests
Note:
See TracChangeset
for help on using the changeset viewer.