What would be a good way to compare two Stream instances in Java 8 and find out whether they have the same elements, specifically for purposes of unit testing?<
Stream
static void assertStreamEquals(Stream> s1, Stream> s2) { Iterator> iter1 = s1.iterator(), iter2 = s2.iterator(); while(iter1.hasNext() && iter2.hasNext()) assertEquals(iter1.next(), iter2.next()); assert !iter1.hasNext() && !iter2.hasNext(); }