/** * Check for some possible corner cases, because {@link IntIteratorUtils.MergeIntIterator} is * implemented using packing ints within longs, that is prone to some overflow or sign bit extension bugs */ @Test public void testOverflow() { List<IntList> lists = Lists.newArrayList( IntLists.singleton(Integer.MIN_VALUE), IntLists.singleton(Integer.MIN_VALUE), IntLists.singleton(-1), IntLists.singleton(0), IntLists.singleton(MAX_VALUE) ); for (int i = 0; i < lists.size() + 1; i++) { assertAscending(mergeAscending(iteratorsFromLists(lists))); Collections.rotate(lists, 1); } Collections.shuffle(lists); assertAscending(mergeAscending(iteratorsFromLists(lists))); }