Changeset 9b5fa6 for src/Graph/unittests


Ignore:
Timestamp:
Jul 5, 2017, 7:43:00 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_oldresults, IndependentFragmentGrids_IntegrationTest
Children:
6e1c14
Parents:
41eed2
git-author:
Frederik Heber <frederik.heber@…> (05/19/17 09:27:11)
git-committer:
Frederik Heber <frederik.heber@…> (07/05/17 19:43:00)
Message:

Extended BreadthFirstSearchGatherer to allow BFS with limited discovery horizon.

  • TESTS: extended unit test as well.
Location:
src/Graph/unittests
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/Graph/unittests/BreadthFirstSearchGathererUnitTest.cpp

    r41eed2 r9b5fa6  
    105105  CPPUNIT_ASSERT_EQUAL (compareids, atomids);
    106106};
     107
     108/** Tests whether operator() with limited distance works.
     109 */
     110void BreadthFirstSearchGathererTest::limitedDistanceTest()
     111{
     112  // create linear test graph
     113  prepareLinearGraph();
     114
     115  // call operator
     116  BreadthFirstSearchGatherer gatherer(*BGCreator);
     117  {
     118    std::vector<atomId_t> atomids = gatherer(0, 3);
     119
     120    // create comparator set
     121    std::vector<atomId_t> compareids;
     122    compareids += 1,2,3,4;
     123    CPPUNIT_ASSERT_EQUAL ((size_t)4, atomids.size());
     124    CPPUNIT_ASSERT_EQUAL (compareids, atomids);
     125  }
     126  // zero distance means just find the initial node
     127  {
     128    std::vector<atomId_t> atomids = gatherer(0, 0);
     129
     130    // create comparator set
     131    std::vector<atomId_t> compareids;
     132    compareids += 1;
     133    CPPUNIT_ASSERT_EQUAL ((size_t)1, atomids.size());
     134    CPPUNIT_ASSERT_EQUAL (compareids, atomids);
     135  }
     136  // negative distance means find all
     137  {
     138    std::vector<atomId_t> atomids = gatherer(0, -1);
     139
     140    // create comparator set
     141    std::vector<atomId_t> compareids;
     142    compareids += 1,2,3,4,5;
     143    CPPUNIT_ASSERT_EQUAL ((size_t)5, atomids.size());
     144    CPPUNIT_ASSERT_EQUAL (compareids, atomids);
     145  }
     146};
  • src/Graph/unittests/BreadthFirstSearchGathererUnitTest.hpp

    r41eed2 r9b5fa6  
    2525    CPPUNIT_TEST_SUITE( BreadthFirstSearchGathererTest) ;
    2626    CPPUNIT_TEST ( operatorTest );
     27    CPPUNIT_TEST ( limitedDistanceTest );
    2728    CPPUNIT_TEST_SUITE_END();
    2829
     
    3132      void tearDown();
    3233      void operatorTest();
     34      void limitedDistanceTest();
    3335
    3436private:
Note: See TracChangeset for help on using the changeset viewer.