Changeset e47ac7 for src/FunctionApproximation/unittests
- Timestamp:
- Nov 4, 2016, 9:37:50 AM (8 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_StructOpt_integration_tests, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, 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_ChronosMutex, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, GeometryObjects, Gui_displays_atomic_force_velocity, IndependentFragmentGrids_IntegrationTest, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, RotateToPrincipalAxisSystem_UndoRedo, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, ThirdParty_MPQC_rebuilt_buildsystem, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, Ubuntu_1604_changes, stable
- Children:
- c7aac9
- Parents:
- 16c6f7
- git-author:
- Frederik Heber <heber@…> (10/02/16 13:59:35)
- git-committer:
- Frederik Heber <heber@…> (11/04/16 09:37:50)
- Location:
- src/FunctionApproximation/unittests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/FunctionApproximation/unittests/ExtractorsUnitTest.cpp
r16c6f7 re47ac7 72 72 } 73 73 74 /** UnitTest for gatherAll DistanceArguments()74 /** UnitTest for gatherAllSymmetricDistances() 75 75 */ 76 void ExtractorsTest::gatherAll DistanceArgumentsTest()76 void ExtractorsTest::gatherAllSymmetricDistancesTest() 77 77 { 78 78 // create positions … … 90 90 // create distances 91 91 FunctionModel::arguments_t args = 92 Extractors::gatherAll DistanceArguments(positions, charges, 0);93 CPPUNIT_ASSERT_EQUAL( (size_t)(5*4 ), args.size() );92 Extractors::gatherAllSymmetricDistances(positions, charges, 0); 93 CPPUNIT_ASSERT_EQUAL( (size_t)(5*4/2), args.size() ); 94 94 95 95 // check created args 96 for (size_t i=0; i< 5*4; ++i)96 for (size_t i=0; i< (5*4)/2; ++i) 97 97 CPPUNIT_ASSERT( (args[i].distance >= 0) && (args[i].distance <= 4)); 98 98 } 99 100 /** UnitTest for gatherPositionsFromFragment()101 */102 void ExtractorsTest::gatherPositionsFromFragmentTest()103 {104 // create positions105 Fragment::positions_t positions;106 Fragment::position_t pos(3, 0.);107 for (double i = 0; i < 5; i+=1.) {108 pos[0] = i;109 positions.push_back(pos);110 }111 112 // create charges113 Fragment::charges_t charges;114 charges += 6., 6., 1., 1., 1.;115 116 {117 // extract carbon pairs118 Fragment::charges_t carbonpair;119 carbonpair += 6.,6.;120 Fragment::positions_t filtered_positions =121 Extractors::gatherPositionsFromFragment(positions, charges, carbonpair);122 CPPUNIT_ASSERT_EQUAL( (size_t)2, filtered_positions.size() );123 }124 125 {126 // extract hydrogen triple127 Fragment::charges_t hydrogentriple;128 hydrogentriple += 1.,1.,1.;129 Fragment::positions_t filtered_positions =130 Extractors::gatherPositionsFromFragment(positions, charges, hydrogentriple);131 CPPUNIT_ASSERT_EQUAL( (size_t)3, filtered_positions.size() );132 }133 }134 135 /** UnitTest for gatherDistancesFromFragment()136 */137 void ExtractorsTest::gatherDistancesFromFragmentTest()138 {139 // create positions140 Fragment::positions_t positions;141 Fragment::position_t pos(3, 0.);142 for (double i = 0; i < 5; i+=1.) {143 pos[0] = i;144 positions.push_back(pos);145 }146 147 // create charges148 Fragment::charges_t charges;149 charges += 6., 6., 1., 1., 1.;150 151 {152 // extract carbon pairs153 Fragment::charges_t carbonpair;154 carbonpair += 6.,6.;155 FunctionModel::arguments_t args =156 Extractors::gatherDistancesFromFragment(positions, charges, carbonpair, 0);157 CPPUNIT_ASSERT_EQUAL( (size_t)1, args.size() );158 }159 160 {161 // extract hydrogen triple162 Fragment::charges_t hydrogentriple;163 hydrogentriple += 1.,1.,1.;164 FunctionModel::arguments_t args =165 Extractors::gatherDistancesFromFragment(positions, charges, hydrogentriple, 0);166 CPPUNIT_ASSERT_EQUAL( (size_t)3, args.size() );167 }168 }169 170 /** UnitTest for reorderArgumentsByIncreasingDistance()171 */172 void ExtractorsTest::reorderArgumentsByIncreasingDistanceTest()173 {174 // prepare some arguments175 FunctionModel::arguments_t args;176 argument_t arg;177 arg.distance = 0.1;178 args.push_back(arg);179 arg.distance = 0.9;180 args.push_back(arg);181 arg.distance = 0.3;182 args.push_back(arg);183 CPPUNIT_ASSERT_EQUAL( (size_t)3, args.size() );184 FunctionModel::list_of_arguments_t listargs(1, args);185 186 // reorder187 FunctionModel::list_of_arguments_t listargs_sorted =188 Extractors::reorderArgumentsByIncreasingDistance(listargs);189 CPPUNIT_ASSERT_EQUAL( (size_t)1, listargs_sorted.size() );190 FunctionModel::arguments_t args_sorted = *(listargs_sorted.begin());191 CPPUNIT_ASSERT_EQUAL( (size_t)3, args_sorted.size() );192 CPPUNIT_ASSERT_EQUAL( args[0].distance, args_sorted[0].distance );193 CPPUNIT_ASSERT_EQUAL( args[1].distance, args_sorted[2].distance );194 CPPUNIT_ASSERT_EQUAL( args[2].distance, args_sorted[1].distance );195 } -
src/FunctionApproximation/unittests/ExtractorsUnitTest.hpp
r16c6f7 re47ac7 22 22 { 23 23 CPPUNIT_TEST_SUITE( ExtractorsTest) ; 24 CPPUNIT_TEST ( gatherAllDistanceArgumentsTest ); 25 CPPUNIT_TEST ( reorderArgumentsByIncreasingDistanceTest ); 26 CPPUNIT_TEST ( gatherPositionsFromFragmentTest ); 27 CPPUNIT_TEST ( gatherDistancesFromFragmentTest ); 24 CPPUNIT_TEST ( gatherAllSymmetricDistancesTest ); 28 25 CPPUNIT_TEST_SUITE_END(); 29 26 … … 31 28 void setUp(); 32 29 void tearDown(); 33 void gatherAllDistanceArgumentsTest(); 34 void reorderArgumentsByIncreasingDistanceTest(); 35 void gatherPositionsFromFragmentTest(); 36 void gatherDistancesFromFragmentTest(); 30 void gatherAllSymmetricDistancesTest(); 37 31 38 32 private:
Note:
See TracChangeset
for help on using the changeset viewer.