Ignore:
Timestamp:
May 31, 2012, 1:25:03 PM (13 years ago)
Author:
Michael Ankele <ankele@…>
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:
9b5eb0
Parents:
30ebdd
git-author:
Michael Ankele <ankele@…> (04/16/12 12:30:32)
git-committer:
Michael Ankele <ankele@…> (05/31/12 13:25:03)
Message:

added string functions to ValueInterface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parameters/unittests/DiscreteValueTest.cpp

    r30ebdd r047cad  
    7676 *
    7777 */
    78 void DiscreteValueTest::isValidValueTest()
     78void DiscreteValueTest::isValidAsStringTest()
    7979{
    8080  // create instance
     
    8282
    8383  // checking valid values
    84   for (int i=1; i<=3;++i)
    85     CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i));
    86 
    87   // checking invalid values
    88   for (int i=-10; i<=0;++i)
    89     CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i));
     84  /*for (int i=1; i<=3;++i)
     85    CPPUNIT_ASSERT_EQUAL(true, test.isValidAsString(toString(i)));
     86
     87  // checking invalid values
     88  for (int i=-10; i<=0;++i)
     89    CPPUNIT_ASSERT_EQUAL(false, test.isValidAsString(toString(i)));
    9090  for (int i=4; i<=0;++i)
    91     CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i));
     91    CPPUNIT_ASSERT_EQUAL(false, test.isValidAsString(toString(i)));*/
    9292}
    9393
     
    121121  // adding values 4,5,6
    122122  for (int i=4; i<=6;++i) {
    123     CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i));
     123    CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
    124124    test.appendValidValue(i);
    125     CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i));
     125    CPPUNIT_ASSERT_EQUAL(true, test.isValid(i));
    126126  }
    127127
     
    137137  // checking valid values
    138138  for (int i=1; i<=6;++i)
    139     CPPUNIT_ASSERT_EQUAL(true, test.isValidValue(i));
    140 
    141   // checking invalid values
    142   for (int i=-10; i<=0;++i)
    143     CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i));
     139    CPPUNIT_ASSERT_EQUAL(true, test.isValid(i));
     140
     141  // checking invalid values
     142  for (int i=-10; i<=0;++i)
     143    CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
    144144
    145145  // checking invalid values
    146146  for (int i=7; i<=10;++i)
    147     CPPUNIT_ASSERT_EQUAL(false, test.isValidValue(i));
     147    CPPUNIT_ASSERT_EQUAL(false, test.isValid(i));
    148148}
    149149
     
    183183 *
    184184 */
    185 void DiscreteValueTest::settergetterValueTest()
     185void DiscreteValueTest::settergetterAsStringTest()
    186186{
    187187  // create instance
     
    191191#ifndef NDEBUG
    192192  std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
    193   CPPUNIT_ASSERT_THROW(test.getValue(), Assert::AssertionFailure);
     193  CPPUNIT_ASSERT_THROW(test.getAsString(), Assert::AssertionFailure);
    194194#endif
    195195
    196196  // setting invalid, throws
    197 #ifndef NDEBUG
    198   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
    199   CPPUNIT_ASSERT_THROW(test.setValue(4), Assert::AssertionFailure);
    200 #endif
    201 #ifndef NDEBUG
    202   std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
    203   CPPUNIT_ASSERT_THROW(test.setValue(0), Assert::AssertionFailure);
     197/*#ifndef NDEBUG
     198  std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
     199  CPPUNIT_ASSERT_THROW(test.setAsString(toString(4)), Assert::AssertionFailure);
     200#endif
     201#ifndef NDEBUG
     202  std::cout << "The following Assert failures are intended and do not indicate a failure of the test." << std::endl;
     203  CPPUNIT_ASSERT_THROW(test.setAsString(toString(0)), Assert::AssertionFailure);
    204204#endif
    205205
    206206  // checking all valid ones
    207207  for (int i=1; i<=3;++i) {
    208     test.setValue(i);
    209     CPPUNIT_ASSERT_EQUAL(i, test.getValue());
    210   }
     208    test.setAsString(toString(i));
     209    CPPUNIT_ASSERT_EQUAL(toString(i), test.getAsString());
     210  }*/
    211211}
    212212
     
    220220    DiscreteValue<int> test(ValidValues);
    221221    DiscreteValue<int> instance(ValidValues);
    222     test.setValue(1);
    223     instance.setValue(1);
     222    test.set(1);
     223    instance.set(1);
    224224
    225225    // same value, same range
     
    230230    // different value, same range
    231231    {
    232       const int oldvalue = instance.getValue();
    233       instance.setValue(2);
     232      const int oldvalue = instance.get();
     233      instance.set(2);
    234234      CPPUNIT_ASSERT(test != instance);
    235       instance.setValue(oldvalue);
     235      instance.set(oldvalue);
    236236    }
    237237  }
     
    241241    instance.appendValidValue(4);
    242242
    243     test.setValue(1);
    244     instance.setValue(1);
     243    test.set(1);
     244    instance.set(1);
    245245
    246246    // same value, same range
     
    251251    // different value, same range
    252252    {
    253       const int oldvalue = instance.getValue();
    254       instance.setValue(2);
     253      const int oldvalue = instance.get();
     254      instance.set(2);
    255255      CPPUNIT_ASSERT(test != instance);
    256       instance.setValue(oldvalue);
    257     }
    258   }
    259 }
     256      instance.set(oldvalue);
     257    }
     258  }
     259}
Note: See TracChangeset for help on using the changeset viewer.