public void order(List<?> actual, Object ... expected) { if (expected == null) expected = EMPTY_OBJECTS; order(Arrays.asList(expected), actual); }
public void testArrayCopy() { int arrayLength = 1000; int maxValue = Integer.MAX_VALUE; long[] res = new long[arrayLength]; long[] expected = new long[arrayLength]; for (int i = 0; i < arrayLength; i++) { res[i] = myRand.nextInt(maxValue); expected[i] = res[i]; } long[] copy = LongCollections.arrayCopy(res); CHECK.order(expected, copy); }
public void unordered(List<?> expectedList, List<?> actualList) { expectedList = sort(expectedList); actualList = sort(actualList); order(expectedList, actualList); }
public void testAsLongList() { List<Long> arr = new ArrayList<Long>(); for (int i = 0; i < 10; i += 2) { arr.add(Long.valueOf(i)); } LongList res = asLongList(arr); CHECK.order(LongArray.create(0,2,4,6,8), res); arr.clear(); res = asLongList(arr); assertEquals(res, LongList.EMPTY); }
public void testCreate() { List<LongArray> list = new ArrayList<LongArray>(); list.add(LongArray.create(1, 2, 5, 10)); list.add(LongArray.create(-3, 2, 3, 4, 11)); LongArray union = new LongArray(new LongUnionIterator(list)); CHECK.order(union, -3, 1, 2, 3, 4, 5, 10, 11); }
public void testCreate() { List<LongArray> list = new ArrayList<LongArray>(); list.add(LongArray.create(1, 2, 5, 10, 20)); list.add(LongArray.create(1, 5, 21, 30, 40)); LongArray intersection = new LongArray(new LongIntersectionIterator(list)); CHECK.order(intersection, 1, 5); }
private void checkToMethods(long... values) { LongList expected = LongArray.create(values); int length = values.length; long[] tmp = new long[length]; for (LongList arr : createLongListVariants(values)) { CHECK.order(expected.toNativeArray(0, tmp, 0, length), arr.toNativeArray(0, tmp, 0, length)); CHECK.order(expected.toNativeArray(), arr.toNativeArray()); CHECK.order(expected.toList(), arr.toList()); } }
public void testArrayCopy() { long[] arr = {0, 1, 2, 3, 4, 5}; long[] res = LongCollections.arrayCopy(arr, 2, 3); long[] expected = {2, 3, 4}; CHECK.order(res, expected); res = LongCollections.arrayCopy(arr, 2, 0); assertEquals(res, IntegersUtils.EMPTY_LONGS); }
public void checkToWritableSortedUnique(long[] array) { LongArray expected = LongArray.copy(array); expected.sortUnique(); LongArray actual = toWritableSortedUnique(array); CHECK.order(expected, actual); }
public void checkAllSubLists(LongList list, ArrayList<Long>[] lists, int size) { int i = 0; for (LongArray array : allSubLists(list)) { CHECK.order(LongCollections.asLongList(lists[i++]), array); } assertEquals(size, i); }
public void testRemoveAllAtSorted() { LongArray a = new LongArray(LongProgression.arithmetic(0, 20)); LongCollections.removeAllAtSorted(a, IntArray.create(0, 3, 4, 7, 10, 11, 12, 13, 19)); CHECK.order(a.iterator(), 1, 2, 5, 6, 8, 9, 14, 15, 16, 17, 18); LongCollections.removeAllAtSorted(a, IntArray.create(1, 2, 3, 4, 9)); CHECK.order(a.iterator(), 1, 9, 14, 15, 16, 18); }
public void testRemoveSorted() { array = LongArray.create(0, 20, 21, 30, 35, 80); assertTrue(array.removeSorted(20)); CHECK.order(LongArray.create(0, 21, 30, 35, 80), array); array.clear(); assertFalse(array.removeSorted(0)); array.addAll(0, 1, 1, 1, 2, 10); assertTrue(array.removeSorted(1)); CHECK.order(array, 0, 1, 1, 2, 10); }
public void testSimpleCreateFromSorted2() { LongList base = LongArray.create(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); WritableIntList indices = IntArray.create(0, 2, 4, 6, 8); LongListRemovingDecorator.prepareSortedIndices(indices); LongListRemovingDecorator arr = LongListRemovingDecorator.createFromPrepared(base, indices); CHECK.order(arr.iterator(), 1, 3, 5, 7, 9); }
private void checkNewSetCreator(LongArray... arrays) { CHECK.order(creator.get(arrays).iterator(), expected.get(arrays).iterator()); if (arrays.length == 2 && getCurrentStatus(0) == getCurrentStatus(1)) { CHECK.order(creator.get(arrays[1], arrays[0]).iterator(), expected.get(arrays[1], arrays[0]).iterator()); } }
protected void checkSet(LongList collection, long[]... v) { LongArray r = new LongArray(); for (long[] ints : v) { r.addAll(ints); } r.sortUnique(); long[] expected = r.toNativeArray(); CHECK.order(collection.iterator(), expected); }
public void testEmptyCase() { LongArray list = LongArray.create(2, 3, 9); IntIterator indices = IntArray.create().iterator(); LongIndexedIterator res = new LongIndexedIterator(list, indices); CHECK.order(LongArray.create().iterator(), res); }
public void checkToNativeArray(LongArray array) { long[] expected = array.toNativeArray(); LongSet set = LongTreeSet.createFromSortedUnique(array); LongIterable[] iterables = {array, set, array.iterator(), set.iterator(), LongIterators.unionIterator(array, array.isEmpty() ? LongIterator.EMPTY : array.subList(0, 1))}; for (LongIterable iterable: iterables) { CHECK.order(expected, LongCollections.toNativeArray(iterable)); } }
private static void testRevPerm(IntArray perms) { IntArray rev = new IntArray(perms); IntegersUtils.reversePerm(rev); int n = perms.size(); IntArray e = new IntArray(n); for (int i = 0; i < n; ++i) { e.add(perms.get(rev.get(i))); } CHECK.order(IntProgression.arithmetic(0, n).iterator(), e.iterator()); }
public void testIteratorSetValue() { LongParallelListMap.Iterator it = myMap.iterator(1); assertNotNull(it.iterator()); assertFalse(it.hasValue()); for (; it.hasNext(); it.next()) { it.setRight(1, it.getRight(1) - 11); } assertTrue(it.hasValue()); LongIterator expected = LongArray.create(1, 0, 10, 20, 30).iterator(); CHECK.order(myMap.valuesIterator(0, myMap.size()), expected); }