Coverage Report - net.sourceforge.combean.test.graph.alg.traversal.TestDFSNodeNumberingVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
TestDFSNodeNumberingVisitor
91%
20/22
100%
2/2
1,2
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 20.02.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.test.graph.alg.traversal;
 23  
 
 24  
 import junit.framework.TestCase;
 25  
 import net.sourceforge.combean.graph.NumberNode;
 26  
 import net.sourceforge.combean.graph.alg.traversal.DFSNodeNumberingVisitor;
 27  
 import net.sourceforge.combean.graph.alg.traversal.RecursiveDFSImpl;
 28  
 import net.sourceforge.combean.interfaces.graph.Graph;
 29  
 import net.sourceforge.combean.interfaces.graph.alg.traverse.DepthFirstSearch;
 30  
 import net.sourceforge.combean.samples.simplegraphs.DirectedCircle;
 31  
 
 32  
 /**
 33  
  * @author schickin
 34  
  *
 35  
  */
 36  
 public class TestDFSNodeNumberingVisitor extends TestCase {
 37  
     
 38  3
     private DFSNodeNumberingVisitor numberingVis = null;
 39  3
     private DepthFirstSearch dfsAlg = null;
 40  
     
 41  
     private static final int CIRCLESIZE = 5;
 42  3
     private Graph circle = null;
 43  
 
 44  
     public static void main(String[] args) {
 45  0
         junit.textui.TestRunner.run(TestDFSNodeNumberingVisitor.class);
 46  0
     }
 47  
 
 48  
     /*
 49  
      * @see TestCase#setUp()
 50  
      */
 51  
     protected void setUp() throws Exception {
 52  3
         super.setUp();
 53  
         
 54  3
         this.circle = new DirectedCircle(CIRCLESIZE);
 55  3
         this.dfsAlg = new RecursiveDFSImpl();
 56  3
         this.dfsAlg.setGraph(this.circle);
 57  3
         this.numberingVis = new DFSNodeNumberingVisitor();
 58  3
         this.dfsAlg.setVisitor(this.numberingVis);
 59  3
     }
 60  
 
 61  
     /*
 62  
      * @see TestCase#tearDown()
 63  
      */
 64  
     protected void tearDown() throws Exception {
 65  3
         super.tearDown();
 66  3
     }
 67  
 
 68  
     /**
 69  
      * Constructor for TestDFSNodeNumberingVisitor.
 70  
      * @param name
 71  
      */
 72  
     public TestDFSNodeNumberingVisitor(String name) {
 73  3
         super(name);
 74  3
     }
 75  
 
 76  
     public final void testGetDfsNum() {
 77  3
         this.dfsAlg.setLocalStartNode(new NumberNode(0));
 78  3
         this.dfsAlg.run();
 79  18
         for (int i = 0; i < CIRCLESIZE; i++) {
 80  15
             NumberNode v = new NumberNode(i);
 81  15
             assertEquals("by construction dfs number must equal node number",
 82  
                     i+1, this.numberingVis.getDfsNum(v));
 83  
         }
 84  3
     }
 85  
 
 86  
 }