@Test public void testSetToIterator() { final Set<String> in = new HashSet<String>(2); in.add("1"); in.add("2"); final Object[] out = toArray(IterableLike.of(in)); assertThat(out).containsExactly("1", "2"); }
@Test public void testListToIterator() { final List<String> in = new ArrayList<String>(2); in.add("1"); in.add("2"); final Object[] out = toArray(IterableLike.of(in)); assertThat(out).containsExactly("1", "2"); }
@Test public void testEmptyListToIterator() { final Object[] out = toArray(IterableLike.of(new ArrayList<Integer>())); assertThat(out).isEmpty(); }
@Test public void testEmptyArrayToIterator() { final Object[] out = toArray(IterableLike.of(new int[]{})); assertThat(out).isEmpty(); }
@Test public void testStringArrayToIterator() { final String[] in = new String[]{"1", "2"}; final Object[] out = toArray(IterableLike.of(in)); assertThat(out).containsExactly("1", "2"); }
@Test public void testPrimitiveArrayToIterator() { final int[] in = new int[]{1, 2}; final Object[] out = toArray(IterableLike.of(in)); assertThat(out).containsExactly(1, 2); }
@Test public void testIterableToIterator() { final Iterable<String> in = new Iterable<String>() { @Override public Iterator<String> iterator() { final List<String> tmp = new ArrayList<String>(); tmp.add("1"); tmp.add("2"); return tmp.iterator(); } }; final Object[] out = toArray(IterableLike.of(in)); assertThat(out).containsExactly("1", "2"); }