Coverage Report - net.sourceforge.combean.test.samples.simplegraphs.TestDirectedCircle
 
Classes in this File Line Coverage Branch Coverage Complexity
TestDirectedCircle
92%
24/26
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 10.02.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.test.samples.simplegraphs;
 23  
 
 24  
 import junit.framework.TestCase;
 25  
 import net.sourceforge.combean.graph.NumberNode;
 26  
 import net.sourceforge.combean.interfaces.graph.Edge;
 27  
 import net.sourceforge.combean.interfaces.graph.EdgeIterator;
 28  
 import net.sourceforge.combean.interfaces.graph.Node;
 29  
 import net.sourceforge.combean.interfaces.graph.NodeIterator;
 30  
 import net.sourceforge.combean.samples.simplegraphs.DirectedCircle;
 31  
 
 32  
 /**
 33  
  * @author schickin
 34  
  *
 35  
  */
 36  
 public class TestDirectedCircle extends TestCase {
 37  
     
 38  
     private static final int CIRCLESIZE = 5;
 39  3
     private DirectedCircle circle = null;
 40  
     
 41  
     public static void main(String[] args) {
 42  0
         junit.textui.TestRunner.run(TestDirectedCircle.class);
 43  0
     }
 44  
 
 45  
     /*
 46  
      * @see TestCase#setUp()
 47  
      */
 48  
     protected void setUp() throws Exception {
 49  3
         super.setUp();
 50  
         
 51  3
         this.circle = new DirectedCircle(CIRCLESIZE);
 52  3
     }
 53  
 
 54  
     /*
 55  
      * @see TestCase#tearDown()
 56  
      */
 57  
     protected void tearDown() throws Exception {
 58  3
         super.tearDown();
 59  3
     }
 60  
 
 61  
     /**
 62  
      * Constructor for TestDirectedCircle.
 63  
      * @param name
 64  
      */
 65  
     public TestDirectedCircle(String name) {
 66  3
         super(name);
 67  3
     }
 68  
     
 69  
         public final void testGetNeighbors() {
 70  3
                 EdgeIterator it = null;
 71  3
                 Edge e = null;
 72  3
                 Node v = null;
 73  
 
 74  3
                 int i = 0;
 75  3
                 NodeIterator allNodesIt = this.circle.getAllNodesIterator();
 76  18
                 while (allNodesIt.hasNext()) {
 77  15
                     Node w = allNodesIt.next();
 78  
 
 79  15
                         it = this.circle.getIncidentEdges(w);
 80  15
                         assertTrue("every node has one neighbor", it.hasNext());
 81  15
                         e = it.next();
 82  15
                         v = this.circle.getOtherNode(e, w);
 83  15
                         assertEquals((i+1)%CIRCLESIZE, ((NumberNode)v).getNodeNum());
 84  15
                         assertFalse(it.hasNext());
 85  
                         
 86  15
                         i++;
 87  15
                 }
 88  3
         }
 89  
 
 90  
 }