public void testRetainSimple() { checkRetain(LongArray.create(Long.MIN_VALUE), LongArray.create(Long.MIN_VALUE + 1), false); checkRetain(LongArray.create(Long.MIN_VALUE), LongArray.create(Long.MIN_VALUE + 1), true); checkRetain(LongArray.create(2, 3, 5, 6, 8, 9, 10, 13, 3, 4, 5, 3), LongArray.create(1, 4, 5, 6, 7, 8, 10, 15), false); checkRetain(LongArray.create(0, 1, 2, 3, 5, 3, 2, 1, -10), LongArray.create(0, 2, -10), false); checkRetain(LongProgression.arithmetic(0, 20, 1), LongProgression.arithmetic(1, 15, 2), true); checkRetain(LongArray.create(0, 1, 2, 3, 10), LongArray.create(0, 2, 10), true); }
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 testCopy() { LongArray copiedArray = LongArray.copy(new long[]{10, 20, 30}); CHECK.order(copiedArray, LongArray.create(10, 20, 30)); }
public void testFromCollection() { List<Long> l = new ArrayList<Long>(); l.add(2L); l.add(3L); l.add(9L); LongArray a = LongArray.create(l); CHECK.order(a.toNativeArray(), 2, 3, 9); LongList il = LongCollections.asLongList(l); CHECK.order(il.toNativeArray(), 2, 3, 9); }
public void testGet2() { LongList[] arrays = {LongArray.create(0, 1, 2), LongArray.create(3, 4), LongArray.create(5)}; LongListConcatenation res = new LongListConcatenation(arrays); assertEquals(6, res.size()); assertEquals(3, res.getSliceCount()); for(int i = 0; i < 6; i++) { assertEquals(i, res.get(i)); } }
public void testGetBounds() { if (!isSortedSet()) return; LongArray values = create(MIN, MIN + 1, 0, 1, MAX - 1, MAX); for (LongArray array : LongCollections.allSubLists(values)) { checkBounds(array); } }
public void testSet() { for (WritableLongList list: createWritableLongLists(0, 1, 2, -1, 1, 3)) { list.set(0, 10); list.setAll(3, LongArray.create(5, 31, 36, 100), 1, 2); checkCollection(list, 10, 1, 2, 31, 36, 3); } }
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); }
public void testNoSuchElementExceptionCase() { LongArray list = LongArray.create(2, 3, 9); IntListIterator indices = IntArray.create(0, 2).iterator(); LongListIndexedIterator res = new LongListIndexedIterator(list, indices); // check for NSEE try { res.value(); fail("not caught NSEE"); } catch(NoSuchElementException ex) { } } }
public void setUp() throws Exception { super.setUp(); IntIterator arr1 = IntArray.create(1, 2, 3, 4, 5).iterator(); LongIterator arr2 = LongArray.create(5, 10, 15, 20, 25).iterator(); res = IntLongIterators.pair(arr1, arr2); }
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 testSimple() { LongList[] lists = {LongList.EMPTY, new LongList.Single(10), LongArray.create(0, 1, 2), LongProgression.Arithmetic.range(3), null}; for (LongList list : lists) { assertEquals(0, comparator.compare(list, list)); } assertEquals(-1, comparator.compare(null, LongArray.create(0, 1, 2))); assertEquals(0, comparator.compare(lists[2], lists[3])); assertEquals(0, comparator.compare(lists[2], lists[2].iterator())); } }
public void testNoSuchElementExceptionCase() { LongArray list = LongArray.create(2, 3, 9); IntIterator indices = IntArray.create(0, 2).iterator(); LongIndexedIterator res = new LongIndexedIterator(list, indices); while (res.hasNext()) { res.nextValue(); } try { res.nextValue(); fail("not caught NSEE"); } catch(NoSuchElementException ex) { } }
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 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); }