Changeset 12a24c for src/Fragmentation/Homology/unittests
- Timestamp:
- Dec 13, 2012, 9:32:50 AM (12 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:
- 79ac03
- Parents:
- 67db80
- git-author:
- Frederik Heber <heber@…> (09/27/12 13:52:16)
- git-committer:
- Frederik Heber <heber@…> (12/13/12 09:32:50)
- Location:
- src/Fragmentation/Homology/unittests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.cpp
r67db80 r12a24c 43 43 #include <boost/archive/text_iarchive.hpp> 44 44 45 #include <boost/assign.hpp> 46 45 47 #include "Fragmentation/Homology/HomologyContainer.hpp" 46 48 #include "Fragmentation/Graph.hpp" 47 49 48 50 #include "HomologyContainerUnitTest.hpp" 51 52 #include <sstream> 53 54 using namespace boost::assign; 49 55 50 56 #ifdef HAVE_TESTRUNNER … … 60 66 void HomologyContainerTest::setUp() 61 67 { 62 // Keys = new HomologyContainer(keysets, values); 68 // add nodes 69 nodes += 70 FragmentNode(1,1), 71 FragmentNode(1,4), 72 FragmentNode(2,2), 73 FragmentNode(2,4); 74 othernodes += 75 FragmentNode(1,1), 76 FragmentNode(1,4); 77 78 // add edges 79 edges += 80 FragmentEdge(1,1), 81 FragmentEdge(1,4), 82 FragmentEdge(2,2), 83 FragmentEdge(2,4); 84 otheredges += 85 FragmentEdge(1,4), 86 FragmentEdge(2,2); 87 88 // construct graphs 89 HomologyGraph graph(nodes, edges); 90 HomologyGraph othergraph(othernodes, otheredges); 91 92 // place in container 93 Fragment::position_t pos(3, 0.); 94 Fragment::positions_t positions(1, pos); 95 Fragment::charges_t charges(1,1.); 96 Fragment dummy(positions, charges); 97 charges[0] = 6.; 98 positions[0][0] = 1.; 99 Fragment dummy1(positions, charges); 100 positions[0][0] = 2.; 101 Fragment dummy2(positions, charges); 102 container += 103 std::make_pair( graph, std::make_pair(dummy1, 1.) ), 104 std::make_pair( graph, std::make_pair(dummy2, 1.5) ), 105 std::make_pair( othergraph, std::make_pair(dummy, 2.) ); 106 // create HomologyContainer 107 Keys = new HomologyContainer(container); 63 108 } 64 109 … … 73 118 void HomologyContainerTest::InsertionTest() 74 119 { 120 // construct graphs 121 HomologyGraph graph(nodes, edges); 122 123 HomologyContainer::container_t newcontainer; 124 Fragment::position_t pos(3, 0.); 125 Fragment::positions_t positions(1, pos); 126 Fragment::charges_t charges(1,1.); 127 Fragment dummy(positions, charges); 128 newcontainer += 129 std::make_pair( graph, std::make_pair(dummy, 1.) ); 130 131 Keys->insert(newcontainer); 132 133 CPPUNIT_ASSERT_EQUAL( (size_t)4, Keys->container.size() ); 75 134 } 135 136 /** UnitTest for operator==() works correctly. 137 */ 138 void HomologyContainerTest::EqualityTest() 139 { 140 // compare same container 141 CPPUNIT_ASSERT( *Keys == *Keys ); 142 143 // construct other container 144 HomologyGraph graph(nodes, edges); 145 HomologyContainer::container_t newcontainer; 146 Fragment::position_t pos(3, 0.); 147 Fragment::positions_t positions(1, pos); 148 Fragment::charges_t charges(1,1.); 149 Fragment dummy(positions, charges); 150 newcontainer += 151 std::make_pair( graph, std::make_pair(dummy, 1.) ); 152 153 HomologyContainer other(newcontainer); 154 155 CPPUNIT_ASSERT( *Keys != other ); 156 } 157 158 /** UnitTest for serialization 159 */ 160 void HomologyContainerTest::serializeTest() 161 { 162 // serialize 163 std::stringstream outputstream; 164 boost::archive::text_oarchive oa(outputstream); 165 oa << Keys; 166 167 // deserialize 168 HomologyContainer *samekeys = NULL; 169 std::stringstream returnstream(outputstream.str()); 170 boost::archive::text_iarchive ia(returnstream); 171 ia >> samekeys; 172 173 CPPUNIT_ASSERT( samekeys != NULL ); 174 //std::cout << *Keys << std::endl; 175 CPPUNIT_ASSERT_EQUAL( *Keys, *samekeys ); 176 177 delete samekeys; 178 } -
src/Fragmentation/Homology/unittests/HomologyContainerUnitTest.hpp
r67db80 r12a24c 25 25 CPPUNIT_TEST_SUITE( HomologyContainerTest) ; 26 26 CPPUNIT_TEST ( InsertionTest ); 27 CPPUNIT_TEST ( EqualityTest ); 28 CPPUNIT_TEST ( serializeTest ); 27 29 CPPUNIT_TEST_SUITE_END(); 28 30 … … 31 33 void tearDown(); 32 34 void InsertionTest(); 35 void EqualityTest(); 36 void serializeTest(); 33 37 34 38 private: 35 39 HomologyContainer *Keys; 40 HomologyGraph::nodes_t nodes; 41 HomologyGraph::nodes_t othernodes; 42 HomologyGraph::edges_t edges; 43 HomologyGraph::edges_t otheredges; 44 HomologyContainer::container_t container; 36 45 }; 37 46 -
src/Fragmentation/Homology/unittests/Makefile.am
r67db80 r12a24c 47 47 ../libMolecuilderUI.la \ 48 48 ${CodePatterns_LIBS} \ 49 $(BOOST_SERIALIZATION_LDFLAGS) $(BOOST_SERIALIZATION_LIBS) \ 49 50 $(BOOST_LIB) 50 51
Note:
See TracChangeset
for help on using the changeset viewer.