source: src/unittests/AnalysisCorrelationToPointUnitTest.cpp@ 9fb860

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
Last change on this file since 9fb860 was e138de, checked in by Frederik Heber <heber@…>, 15 years ago

Huge change from ofstream * (const) out --> Log().

  • first shift was done via regular expressions
  • then via error messages from the code
  • note that class atom, class element and class molecule kept in parts their output stream, was they print to file.
  • make check runs fine
  • MISSING: Verbosity is not fixed for everything (i.e. if no endl; is present and next has Verbose(0) ...)

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 * AnalysisCorrelationToPointUnitTest.cpp
3 *
4 * Created on: Oct 13, 2009
5 * Author: heber
6 */
7
8using namespace std;
9
10#include <cppunit/CompilerOutputter.h>
11#include <cppunit/extensions/TestFactoryRegistry.h>
12#include <cppunit/ui/text/TestRunner.h>
13
14#include "analysis_correlation.hpp"
15#include "AnalysisCorrelationToPointUnitTest.hpp"
16
17#include "atom.hpp"
18#include "boundary.hpp"
19#include "element.hpp"
20#include "molecule.hpp"
21#include "linkedcell.hpp"
22#include "periodentafel.hpp"
23#include "tesselation.hpp"
24
25/********************************************** Test classes **************************************/
26
27// Registers the fixture into the 'registry'
28CPPUNIT_TEST_SUITE_REGISTRATION( AnalysisCorrelationToPointUnitTest );
29
30void AnalysisCorrelationToPointUnitTest::setUp()
31{
32 atom *Walker = NULL;
33
34 // init private all pointers to zero
35 TestList = NULL;
36 TestMolecule = NULL;
37 hydrogen = NULL;
38 tafel = NULL;
39 pointmap = NULL;
40 binmap = NULL;
41 point = NULL;
42
43 // construct element
44 hydrogen = new element;
45 hydrogen->Z = 1;
46 strcpy(hydrogen->name, "hydrogen");
47 strcpy(hydrogen->symbol, "H");
48
49
50 // construct periodentafel
51 tafel = new periodentafel;
52 tafel->AddElement(hydrogen);
53
54 // construct molecule (tetraeder of hydrogens)
55 TestMolecule = new molecule(tafel);
56 Walker = new atom();
57 Walker->type = hydrogen;
58 Walker->node->Init(1., 0., 1. );
59 TestMolecule->AddAtom(Walker);
60 Walker = new atom();
61 Walker->type = hydrogen;
62 Walker->node->Init(0., 1., 1. );
63 TestMolecule->AddAtom(Walker);
64 Walker = new atom();
65 Walker->type = hydrogen;
66 Walker->node->Init(1., 1., 0. );
67 TestMolecule->AddAtom(Walker);
68 Walker = new atom();
69 Walker->type = hydrogen;
70 Walker->node->Init(0., 0., 0. );
71 TestMolecule->AddAtom(Walker);
72
73 // check that TestMolecule was correctly constructed
74 CPPUNIT_ASSERT_EQUAL( TestMolecule->AtomCount, 4 );
75
76 TestList = new MoleculeListClass;
77 TestMolecule->ActiveFlag = true;
78 TestList->insert(TestMolecule);
79
80 // init point
81 point = new Vector(1.,1.,1.);
82
83 // init maps
84 pointmap = CorrelationToPoint( (MoleculeListClass * const)TestList, (const element * const)hydrogen, (const Vector *)point );
85 binmap = NULL;
86
87};
88
89
90void AnalysisCorrelationToPointUnitTest::tearDown()
91{
92 if (pointmap != NULL)
93 delete(pointmap);
94 if (binmap != NULL)
95 delete(binmap);
96
97 // remove
98 delete(TestList);
99 // note that all the atoms are cleaned by TestMolecule
100 delete(point);
101 delete(tafel);
102 // note that element is cleaned by periodentafel
103};
104
105void AnalysisCorrelationToPointUnitTest::CorrelationToPointTest()
106{
107 // do the pair correlation
108 CPPUNIT_ASSERT( pointmap != NULL );
109 CPPUNIT_ASSERT_EQUAL( (size_t)4, pointmap->size() );
110
111};
112
113void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinNoRangeTest()
114{
115 BinPairMap::iterator tester;
116 // put pair correlation into bins and check with no range
117 binmap = BinData( pointmap, 0.5, 0., 0. );
118 CPPUNIT_ASSERT_EQUAL( (size_t)2, binmap->size() );
119 //OutputCorrelation ( binmap );
120 tester = binmap->begin();
121 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
122 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
123
124};
125
126void AnalysisCorrelationToPointUnitTest::CorrelationToPointBinRangeTest()
127{
128 BinPairMap::iterator tester;
129 // ... and check with [0., 2.] range
130 binmap = BinData( pointmap, 0.5, 0., 2. );
131 CPPUNIT_ASSERT_EQUAL( (size_t)5, binmap->size() );
132 //OutputCorrelation ( binmap );
133 tester = binmap->begin();
134 CPPUNIT_ASSERT_EQUAL( 0., tester->first );
135 tester = binmap->find(1.);
136 CPPUNIT_ASSERT_EQUAL( 1., tester->first );
137 CPPUNIT_ASSERT_EQUAL( 3, tester->second );
138
139};
140
141/********************************************** Main routine **************************************/
142
143int main(int argc, char **argv)
144{
145 // Get the top level suite from the registry
146 CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
147
148 // Adds the test to the list of test to run
149 CppUnit::TextUi::TestRunner runner;
150 runner.addTest( suite );
151
152 // Change the default outputter to a compiler error format outputter
153 runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
154 std::cerr ) );
155 // Run the tests.
156 bool wasSucessful = runner.run();
157
158 // Return error code 1 if the one of test failed.
159 return wasSucessful ? 0 : 1;
160};
Note: See TracBrowser for help on using the repository browser.