@Test
public void testIterator() {

  Iterator<Vector.Element> iterator = test.nonZeroes().iterator();
  checkIterator(iterator, gold);
  iterator = test.all().iterator();
  checkIterator(iterator, gold);
  double[] doubles = {0.0, 5.0, 0, 3.0};
  RandomAccessSparseVector zeros = new RandomAccessSparseVector(doubles.length);
  for (int i = 0; i < doubles.length; i++) {
    zeros.setQuick(i, doubles[i]);
  }
  iterator = zeros.iterateNonZero();
  checkIterator(iterator, doubles);
  iterator = zeros.iterator();
  checkIterator(iterator, doubles);
  doubles = new double[]{0.0, 0.0, 0, 0.0};
  zeros = new RandomAccessSparseVector(doubles.length);
  for (int i = 0; i < doubles.length; i++) {
    zeros.setQuick(i, doubles[i]);
  }
  iterator = zeros.iterateNonZero();
  checkIterator(iterator, doubles);
  iterator = zeros.iterator();
  checkIterator(iterator, doubles);
}