public void testConcatenation() { LongListConcatenation concat = new LongListConcatenation(); assertEquals(0, concat.getSliceCount()); checkCollection(concat); concat.addSlice(LongList.EMPTY); assertEquals(1, concat.getSliceCount()); checkCollection(concat); concat.addSlice(myArray); checkCollection(concat); myArray.add(1); checkCollection(concat, 1); concat.addSlice(LongList.EMPTY); checkCollection(concat, 1); LongSegmentedArray segarray = new LongSegmentedArray(); concat.addSlice(segarray); concat.addSlice(LongList.EMPTY); checkCollection(concat, 1); segarray.add(3); checkCollection(concat, 1, 3); myArray.add(2); checkCollection(concat, 1, 2, 3); }
public void testArray_RemoveSubsequentDuplicates() { myArray.addAll(1, 1, 2); myArray.sortUnique(); checkCollection(myArray, 1, 2); myArray.clear(); myArray.addAll(1, 2, 2, 3); myArray.sortUnique(); checkCollection(myArray, 1, 2, 3); myArray.clear(); myArray.addAll(1, 2, 3, 3); myArray.sortUnique(); checkCollection(myArray, 1, 2, 3); myArray.clear(); myArray.addAll(1, 1, 2, 2, 3, 3); myArray.sortUnique(); checkCollection(myArray, 1, 2, 3); }
public void testMap() { int attemptsCount = 10; int size = 200; int maxVal = 10000; for (int attempt = 0; attempt < attemptsCount; attempt++) { LongArray values = generateRandomLongArray(size, UNORDERED, maxVal); LongToLong[] functions = {LongFunctions.SQR, LongFunctions.INC, LongFunctions.DEC, LongFunctions.NEG}; for (LongToLong fun : functions) { long[] expected = values.toNativeArray(); for (int i = 0; i < expected.length; i++) { expected[i] = fun.invoke(expected[i]); } checkCollection(LongCollections.map(fun, values), expected); } } } }