### Question:
IteratorUtils { public static Iterable<boolean[]> powerset(int size) { final int finalSize = size; return new Iterable<boolean[]>() { @Override public Iterator<boolean[]> iterator() { return new PowerSetIterator(finalSize); } }; } private  IteratorUtils(); static Iterable<S> filterClass(Iterable<T> baseIterable, Class<S> targetClass); static Iterable<S> map(Iterable<T> baseIterable, MapFunction<T, S> mapFunction); static Iterable<T> filter(Iterable<T> baseIterable, FilterFunction<T> filter); static Iterable<T> newIterable(Iterator<T> items); @SafeVarargs static Iterable<T> join(Iterable<? extends T>... collections); static Iterator<int[]> permutations(int size); static Iterable<boolean[]> powerset(int size);  }### Answer:
@Test public void testPowersetOne() { boolean[][] expected = new boolean[][]{ new boolean[]{false}, new boolean[]{true}, }; int count = 0; for (boolean[] subset : IteratorUtils.powerset(1)) { assertEquals(Arrays.toString(expected[count]), Arrays.toString(subset)); count++; } assertEquals(expected.length, count); }
@Test public void testPowersetTwo() { boolean[][] expected = new boolean[][]{ new boolean[]{false, false}, new boolean[]{true, false}, new boolean[]{false, true}, new boolean[]{true, true}, }; int count = 0; for (boolean[] subset : IteratorUtils.powerset(2)) { assertEquals(Arrays.toString(expected[count]), Arrays.toString(subset)); count++; } assertEquals(expected.length, count); }
@Test public void testPowersetThree() { boolean[][] expected = new boolean[][]{ new boolean[]{false, false, false}, new boolean[]{true, false, false}, new boolean[]{false, true, false}, new boolean[]{true, true, false}, new boolean[]{false, false, true}, new boolean[]{true, false, true}, new boolean[]{false, true, true}, new boolean[]{true, true, true}, }; int count = 0; for (boolean[] subset : IteratorUtils.powerset(3)) { assertEquals(Arrays.toString(expected[count]), Arrays.toString(subset)); count++; } assertEquals(expected.length, count); }