/*
 * Copyright (c) 2014, Erik Wienhold
 * All rights reserved.
 *
 * Licensed under the BSD 3-Clause License.
 */

package vsr.cobalt.utils;

import java.util.Set;

import org.testng.annotations.Test;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static vsr.cobalt.testing.Utilities.emptySet;
import static vsr.cobalt.testing.Utilities.setOf;

@Test
public class ProductSetTest {

  @Test
  public static class Iterator {

    @Test
    public void returnIterator() {
      final Set<Set<Integer>> s = setOf(setOf(0, 1), setOf(2, 3));

      final ProductSet<Integer> ps = new ProductSet<>(s);

      final ProductSetIterator<Integer> psi = ps.iterator();
      final ProductSetIterator<Integer> xpsi = new ProductSetIterator<>(s);

      while (psi.hasNext() && xpsi.hasNext()) {
        assertEquals(psi.next(), xpsi.next());
      }

      assertFalse(psi.hasNext());
      assertFalse(psi.hasNext());
    }

  }

}

@@ -170,45 +170,52 @@
 ort 
-org.testng.annotations.Test;%0A
+com.google.common.collect.Iterators;
 %0Aimport 
 stat
@@ -202,39 +202,32 @@
 erators;%0Aimport 
-static 
 org.testng.Asser
@@ -225,28 +225,26 @@
 tng.
-Assert.assertEquals;
+annotations.Test;%0A
 %0Aimp
@@ -282,66 +282,12 @@
 sert
-False;%0Aimport static vsr.cobalt.testing.Utilities.emptySet
+True
 ;%0Aim
@@ -734,170 +734,52 @@
     
-while (psi.hasNext() && xpsi.hasNext()) %7B%0A        assertEquals(psi.next(), xpsi.next());%0A      %7D%0A%0A      assertFalse(psi.hasNext());%0A      assertFalse(psi.hasNext(
+assertTrue(Iterators.elementsEqual(psi, xpsi
 ));%0A

simplify equality test in ProductSet#iterator()