- Timestamp:
- Oct 17, 2013, 7:14:21 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, 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:
- 58952a
- Parents:
- e0ae58d
- git-author:
- Frederik Heber <heber@…> (09/27/13 11:25:35)
- git-committer:
- Frederik Heber <heber@…> (10/17/13 07:14:21)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Fragmentation/Summation/SetValues/unittests/SamplingGridUnitTest.cpp
re0ae58d r955051 39 39 #include <cppunit/extensions/TestFactoryRegistry.h> 40 40 #include <cppunit/ui/text/TestRunner.h> 41 42 // include headers that implement a archive in simple text format 43 #include <boost/archive/text_oarchive.hpp> 44 #include <boost/archive/text_iarchive.hpp> 41 45 42 46 #include "SamplingGridUnitTest.hpp" … … 131 135 132 136 // differing windows 133 const double begin_window[3] = { 0.5, 0.5, 0.5 };134 const double end_window[3] = { 1., 1., 1. };137 // const double begin_window[3] = { 0.5, 0.5, 0.5 }; 138 // const double end_window[3] = { 1., 1., 1. }; 135 139 const double otherbegin_window[3] = { 0.45, 0.45, 0.45 }; 136 140 const double otherend_window[3] = { 1.05, 1.05, 1.05 }; … … 422 426 } 423 427 428 429 /** UnitTest for operator==() 430 */ 431 void SamplingGridTest::equality_Test() 432 { 433 const double begin[3] = { 0., 0., 0. }; 434 const double otherbegin[3] = { .5, 0.1, -0.5 }; 435 const double end[3] = { 1., 1., 1. }; 436 const double otherend[3] = { 2., 2., 2. }; 437 const double begin_window[3] = { 0., 0., 0. }; 438 const double otherbegin_window[3] = { .75, 0.1, 0. }; 439 const double end_window[3] = { 1., 1., 1. }; 440 const double otherend_window[3] = { .9, .9, .9 }; 441 442 // create other grid 443 SamplingGrid samegrid(begin, end, 2, values); 444 SamplingGrid differentbegin(otherbegin, end, 2, values); 445 SamplingGrid differentend(begin, otherend, 2, values); 446 SamplingGrid::sampledvalues_t morevalues; 447 { 448 const double othergrid_value = 1.5; 449 for (size_t i=0; i< NUMBEROFSAMPLES(4); ++i) 450 morevalues += othergrid_value; 451 } 452 SamplingGrid differentlevel(begin, end, 4, morevalues); 453 SamplingGrid::sampledvalues_t othervalues; 454 { 455 const double othergrid_value = 1.5; 456 for (size_t i=0; i< NUMBEROFSAMPLES(2); ++i) 457 othervalues += othergrid_value; 458 } 459 SamplingGrid differentvalues(begin, end, 2, othervalues); 460 461 // check for same level, begin, and end 462 CPPUNIT_ASSERT( *grid == *grid ); 463 CPPUNIT_ASSERT( *grid == samegrid ); 464 CPPUNIT_ASSERT( samegrid == *grid); 465 CPPUNIT_ASSERT( *grid != differentbegin); 466 CPPUNIT_ASSERT( differentbegin != *grid); 467 CPPUNIT_ASSERT( *grid != differentend ); 468 CPPUNIT_ASSERT( differentend != *grid ); 469 CPPUNIT_ASSERT( *grid != differentlevel ); 470 CPPUNIT_ASSERT( differentlevel != *grid ); 471 472 // check for all but differing values 473 CPPUNIT_ASSERT( *grid != differentvalues ); 474 CPPUNIT_ASSERT( differentvalues != *grid ); 475 476 // check for different windows 477 SamplingGrid differentwindowbegin(begin, end, 2); 478 differentwindowbegin.setWindow(otherbegin_window, end_window); 479 SamplingGrid differentwindowend(begin, end, 2); 480 differentwindowend.setWindow(begin_window, otherend_window); 481 CPPUNIT_ASSERT( *grid != differentwindowbegin ); 482 CPPUNIT_ASSERT( differentwindowbegin != *grid ); 483 CPPUNIT_ASSERT( *grid != differentwindowend ); 484 CPPUNIT_ASSERT( differentwindowend != *grid ); 485 486 // check against ZeroInstance 487 CPPUNIT_ASSERT( *grid != ZeroInstance<SamplingGrid>() ); 488 CPPUNIT_ASSERT( samegrid != ZeroInstance<SamplingGrid>() ); 489 CPPUNIT_ASSERT( differentbegin != ZeroInstance<SamplingGrid>() ); 490 CPPUNIT_ASSERT( differentend != ZeroInstance<SamplingGrid>() ); 491 CPPUNIT_ASSERT( differentlevel != ZeroInstance<SamplingGrid>() ); 492 CPPUNIT_ASSERT( differentvalues != ZeroInstance<SamplingGrid>() ); 493 CPPUNIT_ASSERT( differentwindowbegin != ZeroInstance<SamplingGrid>() ); 494 CPPUNIT_ASSERT( differentwindowend != ZeroInstance<SamplingGrid>() ); 495 } 496 497 /** UnitTest for serialization 498 */ 499 void SamplingGridTest::serializeTest() 500 { 501 // serialize 502 std::stringstream outputstream; 503 boost::archive::text_oarchive oa(outputstream); 504 oa << grid; 505 506 // deserialize 507 SamplingGrid *samegrid = NULL; 508 std::stringstream returnstream(outputstream.str()); 509 boost::archive::text_iarchive ia(returnstream); 510 ia >> samegrid; 511 512 CPPUNIT_ASSERT( samegrid != NULL ); 513 CPPUNIT_ASSERT( *grid == *samegrid ); 514 515 delete samegrid; 516 }
Note:
See TracChangeset
for help on using the changeset viewer.
