public void testEdge() { try { path.tailEdge(); fail(); } catch (NoSuchElementException ok) { } assertEquals(n[0], path.headNode()); assertEquals(n[0], path.tailNode()); Edge e = newEdge(0); path = path.append(e.asPath()); assertEquals(e, path.tailEdge()); assertEquals(e.n2(), path.tailNode()); e = newEdge(1); path = path.append(e.asPath()); assertEquals(e, path.tailEdge()); assertEquals(e.n2(), path.tailNode()); }
public void testSlices() { Edge[] edges = {newEdge(0), newEdge(1), newEdge(2), newEdge(3)}; for (Edge e : edges) { path = path.append(e.asPath()); } Path p2 = path.slice(1, 3); assertEquals(2, p2.size()); assertEquals(edges[1], p2.steps().iterator().next().tailEdge()); assertEquals(edges[2], p2.tailEdge()); try { path.slice(2, 1); fail("Allowed illegal path slice arguments"); } catch (RuntimeException e) { // ok } p2 = path.slice(1, 1); assertEquals(0, p2.size()); assertEquals(p2.headNode(), p2.tailNode()); assertEquals(n[1], p2.headNode()); p2 = path.headPath(1); assertEquals(1, p2.size()); assertEquals(n[0], p2.headNode()); assertEquals(n[1], p2.tailNode()); try { path.headPath(-1); fail("Allowed illegal head path argument"); } catch (RuntimeException e) { // ok } p2 = path.tailPath(1); assertEquals(1, p2.size()); assertEquals(n[4], p2.tailNode()); assertEquals(n[3], p2.headNode()); try { path.tailPath(-1); fail("Allowed illegal tail path argument"); } catch (RuntimeException e) { // ok } }