Changeset 6e06bd for src/unittests/VectorContentUnittest.cpp
- Timestamp:
- Dec 5, 2010, 12:19:19 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, Candidate_v1.7.0, 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:
- f03705
- Parents:
- 589112 (diff), bbf1bd (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. - File:
-
- 1 moved
-
src/unittests/VectorContentUnittest.cpp (moved) (moved from src/unittests/gslvectorunittest.cpp ) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/unittests/VectorContentUnittest.cpp
r589112 r6e06bd 7 7 8 8 /* 9 * gslvectorunittest.cpp9 * VectorContentUnittest.cpp 10 10 * 11 11 * Created on: Jan 8, 2010 … … 24 24 #include <cppunit/ui/text/TestRunner.h> 25 25 26 #include " gslvectorunittest.hpp"26 #include "VectorContentUnittest.hpp" 27 27 28 28 #ifdef HAVE_TESTRUNNER … … 33 33 34 34 // Registers the fixture into the 'registry' 35 CPPUNIT_TEST_SUITE_REGISTRATION( GSLVectorTest );35 CPPUNIT_TEST_SUITE_REGISTRATION( VectorContentTest ); 36 36 37 37 38 void GSLVectorTest::setUp()38 void VectorContentTest::setUp() 39 39 { 40 v = new GSLVector(3);40 v = new VectorContent(3); 41 41 }; 42 42 43 void GSLVectorTest::tearDown()43 void VectorContentTest::tearDown() 44 44 { 45 45 delete(v); … … 49 49 * 50 50 */ 51 void GSLVectorTest::AccessTest()51 void VectorContentTest::AccessTest() 52 52 { 53 53 // set 54 54 for (int i=0;i<3;i++) 55 v-> Set(i,i);55 v->at(i) = (double)i; 56 56 57 57 // and check 58 58 double *ptr = NULL; 59 59 for (int i=0;i<3;i++) { 60 CPPUNIT_ASSERT_EQUAL( (double)i, v-> Get(i) );60 CPPUNIT_ASSERT_EQUAL( (double)i, v->at(i) ); 61 61 ptr = v->Pointer(i); 62 62 CPPUNIT_ASSERT_EQUAL( (double)i, *ptr ); … … 64 64 65 65 // out of bounds 66 //CPPUNIT_ASSERT_EQUAL(0., v-> Get(3) );67 //CPPUNIT_ASSERT_EQUAL(0., v-> Get(-1) );66 //CPPUNIT_ASSERT_EQUAL(0., v->at(3) ); 67 //CPPUNIT_ASSERT_EQUAL(0., v->at(-1) ); 68 68 }; 69 69 … … 72 72 * 73 73 */ 74 void GSLVectorTest::InitializaionTest()74 void VectorContentTest::InitializaionTest() 75 75 { 76 76 // set zero 77 v-> SetZero();77 v->setZero(); 78 78 for (int i=0;i<3;i++) 79 CPPUNIT_ASSERT_EQUAL( 0., v-> Get(i) );79 CPPUNIT_ASSERT_EQUAL( 0., v->at(i) ); 80 80 81 81 // set basis 82 82 for (int i=0;i<3;i++) { 83 v-> SetBasis(i);83 v->setBasis(i); 84 84 for (int j=0;j<3;j++) 85 CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v-> Get(j) );85 CPPUNIT_ASSERT_EQUAL( i == j ? 1. : 0. , v->at(j) ); 86 86 } 87 87 88 88 // set all 89 v-> SetAll(1.5);89 v->setValue(1.5); 90 90 for (int i=0;i<3;i++) 91 CPPUNIT_ASSERT_EQUAL( 1.5, v-> Get(i) );91 CPPUNIT_ASSERT_EQUAL( 1.5, v->at(i) ); 92 92 }; 93 93 … … 95 95 * 96 96 */ 97 void GSLVectorTest::CopyTest()97 void VectorContentTest::CopyTest() 98 98 { 99 99 // set basis 100 GSLVector*dest = NULL;100 VectorContent *dest = NULL; 101 101 for (int i=0;i<3;i++) { 102 v-> SetBasis(i);103 dest = new GSLVector(v);102 v->setBasis(i); 103 dest = new VectorContent(v); 104 104 for (int j=0;j<3;j++) 105 CPPUNIT_ASSERT_EQUAL( v-> Get(j) , dest->Get(j) );105 CPPUNIT_ASSERT_EQUAL( v->at(j) , dest->at(j) ); 106 106 107 107 delete(dest); … … 112 112 * 113 113 */ 114 void GSLVectorTest::ExchangeTest()114 void VectorContentTest::ExchangeTest() 115 115 { 116 116 // set basis 117 117 for (int i=0;i<3;i++) { 118 v-> SetBasis(i);118 v->setBasis(i); 119 119 v->SwapElements((i)%3,(i+1)%3); 120 120 for (int j=0;j<3;j++) 121 CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v-> Get(j) );121 CPPUNIT_ASSERT_EQUAL( (i+1)%3 == j ? 1. : 0. , v->at(j) ); 122 122 } 123 123 124 124 // set to 1,2,3 and reverse 125 125 for (int i=0;i<3;i++) 126 v-> Set(i,i+1);126 v->at(i) = (double)(i+1); 127 127 v->Reverse(); 128 128 for (int j=0;j<3;j++) 129 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v-> Get(j) );129 CPPUNIT_ASSERT_EQUAL( (double)(3-j), v->at(j) ); 130 130 }; 131 131 132 132 /** UnitTest for operators. 133 133 */ 134 void GSLVectorTest::OperatorIsTest()134 void VectorContentTest::OperatorIsTest() 135 135 { 136 GSLVectorzero(3);137 GSLVectorunit(3);138 zero. SetZero();139 unit. SetZero();140 unit .Set(1,1.);136 VectorContent zero(3); 137 VectorContent unit(3); 138 zero.setZero(); 139 unit.setZero(); 140 unit[1] = 1.; 141 141 // summation and scaling 142 142 CPPUNIT_ASSERT_EQUAL( true, unit.IsOne() ); … … 148 148 /** UnitTest for operators. 149 149 */ 150 void GSLVectorTest::OperatorAlgebraTest()150 void VectorContentTest::OperatorAlgebraTest() 151 151 { 152 GSLVectorzero(3);153 GSLVectorunit(3);154 zero. SetZero();155 unit. SetZero();156 unit .Set(1,1.);152 VectorContent zero(3); 153 VectorContent unit(3); 154 zero.setZero(); 155 unit.setZero(); 156 unit[1] = 1.; 157 157 // summation and scaling 158 158 CPPUNIT_ASSERT_EQUAL( true, (zero+unit).IsOne() );
Note:
See TracChangeset
for help on using the changeset viewer.
