Changeset a7d753 for src/Parser/unittests
- Timestamp:
- Oct 17, 2011, 2:36:47 PM (13 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:
- 84e752
- Parents:
- 3308b6
- git-author:
- Frederik Heber <heber@…> (09/30/11 09:32:43)
- git-committer:
- Frederik Heber <heber@…> (10/17/11 14:36:47)
- Location:
- src/Parser/unittests
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/unittests/DiscreteValueUnitTest.cpp
r3308b6 ra7d753 26 26 #include "Parser/DiscreteValue.hpp" 27 27 28 #include "CodePatterns/toString.hpp" 29 28 30 #ifdef HAVE_TESTRUNNER 29 31 #include "UnitTestMain.hpp" … … 73 75 } 74 76 75 /** Unit test for isValid .76 * 77 */ 78 void DiscreteValueTest::isValid Test()77 /** Unit test for isValidValue. 78 * 79 */ 80 void DiscreteValueTest::isValidValueTest() 79 81 { 80 82 // create instance … … 83 85 // checking valid values 84 86 for (int i=1; i<=3;++i) 85 CPPUNIT_ASSERT_EQUAL(true, test.isValid (i));86 87 // checking invalid values 88 for (int i=-10; i<=0;++i) 89 CPPUNIT_ASSERT_EQUAL(false, test.isValid (i));87 CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i)); 88 89 // checking invalid values 90 for (int i=-10; i<=0;++i) 91 CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i)); 90 92 for (int i=4; i<=0;++i) 91 CPPUNIT_ASSERT_EQUAL(false, test.isValid(i)); 93 CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i)); 94 } 95 96 /** Unit test for isValid. 97 * 98 */ 99 void DiscreteValueTest::isValidTest() 100 { 101 // create instance 102 DiscreteValue<int> test(ValidValues); 103 104 // checking valid values 105 for (int i=1; i<=3;++i) 106 CPPUNIT_ASSERT_EQUAL(true, test.isValid(toString(i))); 107 108 // checking invalid values 109 for (int i=-10; i<=0;++i) 110 CPPUNIT_ASSERT_EQUAL(false, test.isValid(toString(i))); 111 for (int i=4; i<=0;++i) 112 CPPUNIT_ASSERT_EQUAL(false, test.isValid(toString(i))); 92 113 } 93 114 … … 102 123 // adding values 4,5,6 103 124 for (int i=4; i<=6;++i) { 104 CPPUNIT_ASSERT_EQUAL(false, test.isValid (i));125 CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i)); 105 126 test.appendValidValue(i); 106 CPPUNIT_ASSERT_EQUAL(true, test.isValid (i));127 CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i)); 107 128 } 108 129 109 130 // adding same value, throws assertion 131 const size_t size_before = test.ValidValues.size(); 110 132 #ifndef NDEBUG 111 133 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; … … 113 135 CPPUNIT_ASSERT_THROW(test.appendValidValue(i), Assert::AssertionFailure); 114 136 #endif 137 CPPUNIT_ASSERT_EQUAL( size_before, test.ValidValues.size() ); 115 138 116 139 // checking valid values 117 140 for (int i=1; i<=6;++i) 118 CPPUNIT_ASSERT_EQUAL(true, test.isValid (i));119 120 // checking invalid values 121 for (int i=-10; i<=0;++i) 122 CPPUNIT_ASSERT_EQUAL(false, test.isValid (i));141 CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i)); 142 143 // checking invalid values 144 for (int i=-10; i<=0;++i) 145 CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i)); 123 146 124 147 // checking invalid values 125 148 for (int i=7; i<=10;++i) 126 CPPUNIT_ASSERT_EQUAL(false, test.isValid (i));149 CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i)); 127 150 } 128 151 … … 144 167 #ifndef NDEBUG 145 168 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 146 CPPUNIT_ASSERT_THROW(test.set( 4), Assert::AssertionFailure);147 #endif 148 #ifndef NDEBUG 149 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 150 CPPUNIT_ASSERT_THROW(test.set( 0), Assert::AssertionFailure);169 CPPUNIT_ASSERT_THROW(test.set(toString(4)), Assert::AssertionFailure); 170 #endif 171 #ifndef NDEBUG 172 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 173 CPPUNIT_ASSERT_THROW(test.set(toString(0)), Assert::AssertionFailure); 151 174 #endif 152 175 153 176 // checking all valid ones 154 177 for (int i=1; i<=3;++i) { 155 test.set(i); 156 CPPUNIT_ASSERT_EQUAL(i, test.get()); 157 } 158 } 159 160 161 178 test.set(toString(i)); 179 CPPUNIT_ASSERT_EQUAL(toString(i), test.get()); 180 } 181 182 } 183 184 /** Unit test for setValue and getValue. 185 * 186 */ 187 void DiscreteValueTest::settergetterValueTest() 188 { 189 // create instance 190 DiscreteValue<int> test(ValidValues); 191 192 // unset calling of get, throws 193 #ifndef NDEBUG 194 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 195 CPPUNIT_ASSERT_THROW(test.getValue(), Assert::AssertionFailure); 196 #endif 197 198 // setting invalid, throws 199 #ifndef NDEBUG 200 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 201 CPPUNIT_ASSERT_THROW(test.setValue(4), Assert::AssertionFailure); 202 #endif 203 #ifndef NDEBUG 204 std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl; 205 CPPUNIT_ASSERT_THROW(test.setValue(0), Assert::AssertionFailure); 206 #endif 207 208 // checking all valid ones 209 for (int i=1; i<=3;++i) { 210 test.setValue(i); 211 CPPUNIT_ASSERT_EQUAL(i, test.getValue()); 212 } 213 } -
src/Parser/unittests/DiscreteValueUnitTest.hpp
r3308b6 ra7d753 14 14 15 15 #include <cppunit/extensions/HelperMacros.h> 16 #include <string> 16 17 #include <vector> 17 18 18 19 class DiscreteValueTest : public CppUnit::TestFixture … … 20 21 CPPUNIT_TEST_SUITE( DiscreteValueTest ) ; 21 22 CPPUNIT_TEST ( findIndexOfValueTest ); 23 CPPUNIT_TEST ( isValidValueTest ); 22 24 CPPUNIT_TEST ( isValidTest ); 23 25 CPPUNIT_TEST ( appendValidValueTest ); 24 26 CPPUNIT_TEST ( settergetterTest ); 27 CPPUNIT_TEST ( settergetterValueTest ); 25 28 CPPUNIT_TEST_SUITE_END(); 26 29 … … 30 33 31 34 void findIndexOfValueTest(); 35 void isValidValueTest(); 32 36 void isValidTest(); 33 37 void appendValidValueTest(); 34 38 void settergetterTest(); 39 void settergetterValueTest(); 35 40 36 41 private: -
src/Parser/unittests/Makefile.am
r3308b6 ra7d753 4 4 5 5 PARSERTESTSSOURCES = \ 6 ../Parser/unittests/ContinuousValueUnitTest.cpp \ 6 7 ../Parser/unittests/DiscreteValueUnitTest.cpp \ 7 8 ../Parser/unittests/ParserMpqcUnitTest.cpp \ … … 12 13 13 14 PARSERTESTSHEADERS = \ 15 ../Parser/unittests/ContinuousValueUnitTest.hpp \ 14 16 ../Parser/unittests/DiscreteValueUnitTest.hpp \ 15 17 ../Parser/unittests/ParserMpqcUnitTest.hpp \ … … 20 22 21 23 PARSERTESTS = \ 24 ContinuousValueUnitTest \ 22 25 DiscreteValueUnitTest \ 23 26 ParserMpqcUnitTest \ … … 38 41 39 42 43 ContinuousValueUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 44 ../Parser/unittests/ContinuousValueUnitTest.cpp \ 45 ../Parser/unittests/ContinuousValueUnitTest.hpp \ 46 ../Parser/ContinuousValue.hpp \ 47 ../Parser/ContinuousValue_impl.hpp 48 #ContinuousValueUnitTest_LDADD 49 40 50 DiscreteValueUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \ 41 51 ../Parser/unittests/DiscreteValueUnitTest.cpp \
Note:
See TracChangeset
for help on using the changeset viewer.