Esempio n. 1
0
  public void testEquality() {
    checkEqual(path, path, true);
    checkEqual(path, n[0].asPath(), true);
    Path p2 = path.append(newEdge(0).asPath());
    checkEqual(path, p2, false);

    path = path.append(g.anEdge(n[0], n[1]).asPath());
    checkEqual(path, p2, true);

    path = path.tailPath(0);
    checkEqual(path, p2, false);

    p2 = p2.tailPath(0);
    checkEqual(path, p2, true);
  }
Esempio n. 2
0
  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
    }
  }
Esempio n. 3
0
  public void testAppend() {
    Path p2 = n[1].asPath();
    p2 = p2.append(newEdge(1).asPath());

    try {
      Path p3 = path.append(p2);
      fail("Allowed illegal path concatenation");
    } catch (RuntimeException e) {
      // ok
    }
    Path p3 = newEdge(0).asPath();
    path = path.append(p3);
    assertEquals(1, path.size());
    path = path.append(newEdge(1).asPath());
    assertEquals(2, path.size());
    path = path.tailPath(1);
    assertEquals(1, path.size());
    assertEquals(n[1], path.headNode());
    assertEquals(n[2], path.tailNode());
  }