Changeset 4e855e for src/unittests


Ignore:
Timestamp:
Feb 4, 2011, 6:56:38 PM (14 years ago)
Author:
Frederik Heber <heber@…>
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:
febef3
Parents:
fd3788
git-author:
Frederik Heber <heber@…> (02/04/11 18:54:12)
git-committer:
Frederik Heber <heber@…> (02/04/11 18:56:38)
Message:

BondGraph::LoadBondLengthTable() now accepts istream instead of const char *.

  • This has been quite a lot of work because the matrix parsing is involved.
  • Hence, the fix is not really clean, this should get fixed as soon as we deal with the BondGraph implementation.
  • This fixes ticket #130.
Location:
src/unittests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/AnalysisBondsUnitTest.cpp

    rfd3788 r4e855e  
    9292  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 5 );
    9393
    94   // create a small file with table
    95   filename = new string("test.dat");
    96   CPPUNIT_ASSERT(filename != NULL && "could not create string");
    97   ofstream test(filename->c_str());
     94  // create stream with table
     95  std::stringstream test;
    9896  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
    9997  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     
    103101  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
    104102  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    105   test.close();
    106103  BG = new BondGraph(true);
    107104  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
    108105
    109   CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     106  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(test) );
    110107  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    111108  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     
    119116{
    120117  // remove the file
    121   remove(filename->c_str());
    122   delete(filename);
    123118  delete(BG);
    124119
  • src/unittests/BondGraphUnitTest.cpp

    rfd3788 r4e855e  
    9292  CPPUNIT_ASSERT_EQUAL( TestMolecule->getAtomCount(), 4 );
    9393
    94   // create a small file with table
    95   dummyname = new string("dummy.dat");
    96   CPPUNIT_ASSERT(dummyname != NULL && "could not create string");
    97   filename = new string("test.dat");
    98   CPPUNIT_ASSERT(filename != NULL && "could not create string");
    99   ofstream test(filename->c_str());
     94  // create stream with table
    10095  test << ".\tH\tHe\tLi\tBe\tB\tC\n";
    10196  test << "H\t1.\t1.\t1.\t1.\t1.\t1.2\n";
     
    105100  test << "B\t1.\t1.\t1.\t1.\t1.\t1.\n";
    106101  test << "C\t1.2\t1.\t1.\t1.\t1.\t1.5\n";
    107   test.close();
     102  // created bad stream (i.e. non-present file)
     103  dummy.setstate(ios::eofbit);
     104  CPPUNIT_ASSERT(dummy.eof());
    108105  BG = new BondGraph(true);
    109106  CPPUNIT_ASSERT(BG != NULL && "could not create BondGraph");
     
    114111{
    115112  // remove the file
    116   remove(filename->c_str());
    117   delete(filename);
    118   delete(dummyname);
    119113  delete(BG);
    120114
     
    139133void BondGraphTest::LoadTableTest()
    140134{
    141   CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     135  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(test) );
    142136  CPPUNIT_ASSERT_EQUAL( 1., BG->GetBondLength(0,0) );
    143137  CPPUNIT_ASSERT_EQUAL( 1.2, BG->GetBondLength(0,5) );
     
    152146  molecule::iterator Runner = TestMolecule->begin();
    153147  Runner++;
    154   CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(*filename) );
     148  CPPUNIT_ASSERT_EQUAL( true , BG->LoadBondLengthTable(test) );
    155149  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    156150  CPPUNIT_ASSERT_EQUAL( true , (*Walker)->IsBondedTo((*Runner)) );
     
    165159  //atom *Runner = TestMolecule->end->previous;
    166160  //CPPUNIT_ASSERT( TestMolecule->end != Walker );
    167   CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(*dummyname) );
     161  CPPUNIT_ASSERT_EQUAL( false , BG->LoadBondLengthTable(dummy) );
    168162  CPPUNIT_ASSERT_EQUAL( true , BG->ConstructBondGraph(TestMolecule) );
    169163
  • src/unittests/BondGraphUnitTest.hpp

    rfd3788 r4e855e  
    4949
    5050      BondGraph *BG;
    51       string *filename;
    52       string *dummyname;
     51      std::stringstream dummy;
     52      std::stringstream test;
    5353};
    5454
Note: See TracChangeset for help on using the changeset viewer.