source: src/unittests/linearsystemofequationsunittest.cpp@ 9b6b2f

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 9b6b2f was 9b6b2f, checked in by Frederik Heber <heber@…>, 15 years ago

Tests now work with Eclipse ECUT's TestRunner.

  • new switch in configure.ac: --enable-ecut
  • all tests are compiled as single test as before
  • and a new TestRunner test suite that combines all test into a single executable which can be run as CppUnit program in Eclipse (and then gives JUnit like output).
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * linearsystemofequationsunittest.cpp
3 *
4 * Created on: Jan 8, 2010
5 * Author: heber
6 */
7
8using namespace std;
9
10#include <iomanip>
11#include <cppunit/CompilerOutputter.h>
12#include <cppunit/extensions/TestFactoryRegistry.h>
13#include <cppunit/ui/text/TestRunner.h>
14
15#include "linearsystemofequationsunittest.hpp"
16#include "vector.hpp"
17
18#ifdef HAVE_TESTRUNNER
19#include "UnitTestMain.hpp"
20#endif /*HAVE_TESTRUNNER*/
21
22/********************************************** Test classes **************************************/
23
24// Registers the fixture into the 'registry'
25CPPUNIT_TEST_SUITE_REGISTRATION( LinearSystemOfEquationsTest );
26
27
28void LinearSystemOfEquationsTest::setUp()
29{
30 s = new LinearSystemOfEquations(4,4);
31};
32
33void LinearSystemOfEquationsTest::tearDown()
34{
35 delete(s);
36};
37
38/** Unit test for initialization.
39 *
40 */
41void LinearSystemOfEquationsTest::InitializationTest()
42{
43 // Setting A
44 double array[] = { 1., 0., 0., 0.,
45 0., 2., 0., 0.,
46 0., 0., 3., 0.,
47 0., 0., 0., 4. };
48 s->SetA(array);
49
50 // Setting b
51};
52
53/** Unit test for symmetry property.
54 *
55 */
56void LinearSystemOfEquationsTest::SymmetricTest()
57{
58 CPPUNIT_ASSERT_EQUAL( true, s->SetSymmetric(true) );
59 //LinearSystemOfEquations *t = new LinearSystemOfEquations(4,3);
60 //CPPUNIT_ASSERT_EQUAL( true, t->SetSymmetric(true) );
61 //delete(t);
62};
63
64/** Unit test for simple Solve.
65 *
66 */
67void LinearSystemOfEquationsTest::SolveSimpleTest()
68{
69 // set up A and b
70 double m_array[] = { 1., 0., 0., 0.,
71 0., 2., 0., 0.,
72 0., 0., 3., 0.,
73 0., 0., 0., 4. };
74 double v_array[] = { 1., 2., 3., 4. };
75 s->SetA(m_array);
76 s->Setb(v_array);
77
78 // solve
79 double *array = new double[4];
80 s->GetSolutionAsArray(array);
81 for (int i=0;i<4;i++)
82 CPPUNIT_ASSERT_EQUAL( 1., array[i]);
83 delete[](array);
84};
85
86/** Unit test for advanced Solve.
87 *
88 */
89void LinearSystemOfEquationsTest::SolveAdvancedTest()
90{
91 // set up A and b
92 double m_array[] = { 0.18, 0.60, 0.57, 0.96,
93 0.41, 0.24, 0.99, 0.58,
94 0.14, 0.30, 0.97, 0.66,
95 0.51, 0.13, 0.19, 0.85 };
96 double v_array[] = { 1.0, 2.0, 3.0, 4.0 };
97 double x_array[] = { -4.05205022957398, -12.60561139590692, 1.660911626708844, 8.693766928795233 };
98 s->SetA(m_array);
99 s->Setb(v_array);
100
101 // solve
102 double *array = new double[4];
103 s->GetSolutionAsArray(array);
104 for (int i=0;i<4;i++) {
105 CPPUNIT_ASSERT( fabs(x_array[i] - array[i]) < MYEPSILON );
106 }
107 delete[](array);
108};
Note: See TracBrowser for help on using the repository browser.