Fix Path.size() and add test for Path.size().
This commit is contained in:
parent
46436f81f3
commit
e2d1d47beb
@ -176,7 +176,7 @@ public class Path {
|
|||||||
* @return Number of nodes in this path.
|
* @return Number of nodes in this path.
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
return 1 + this.arcs.size();
|
return isEmpty() ? 0 : 1 + this.arcs.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -93,6 +93,16 @@ public class PathTest {
|
|||||||
assertFalse(longLoopPath.isEmpty());
|
assertFalse(longLoopPath.isEmpty());
|
||||||
assertFalse(invalidPath.isEmpty());
|
assertFalse(invalidPath.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSize() {
|
||||||
|
assertEquals(emptyPath.size(), 0);
|
||||||
|
assertEquals(singleNodePath.size(), 1);
|
||||||
|
assertEquals(shortPath.size(), 4);
|
||||||
|
assertEquals(longPath.size(), 5);
|
||||||
|
assertEquals(loopPath.size(), 5);
|
||||||
|
assertEquals(longLoopPath.size(), 10);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsValid() {
|
public void testIsValid() {
|
||||||
|
Loading…
Reference in New Issue
Block a user