Ejemplo n.º 1
0
  @Test
  public void checkIterator() {
    int size = 20;
    IElement singleDummy;

    ArrayList<IElement> dummies = new ArrayList<>();
    for (int i = 0; i < size; i++) {
      singleDummy = mock(this.elementClass);

      /*
       * Nodes are stored with an index, so set it please!
       */
      if (singleDummy instanceof Node) {
        when(((Node) singleDummy).getIndex()).thenReturn(i);
      }
      if (singleDummy instanceof Edge) {
        when(((Edge) singleDummy).getHashString()).thenReturn("" + i);
      }

      dataStructure.add(singleDummy);
      dummies.add(singleDummy);
    }

    Iterator<IElement> elemIterator = dataStructure.iterator();
    while (elemIterator.hasNext()) {
      singleDummy = elemIterator.next();
      assertTrue(dummies.contains(singleDummy));
      dummies.remove(singleDummy);
    }
    assertTrue(dummies.isEmpty());
  }
Ejemplo n.º 2
0
  @Test
  public void checkNullsInIterator() {
    IElement singleDummy;

    dataStructure.reinitializeWithSize(10);
    Iterator<IElement> elemIterator = dataStructure.iterator();
    while (elemIterator.hasNext()) {
      singleDummy = elemIterator.next();
      assertNotNull(singleDummy);
    }
  }