public void testRandom() { int arrLength = 200, attemptsCount = 5; for (int attempt = 0; attempt < attemptsCount; attempt++) { long[] arr = generateRandomLongArray(arrLength, UNORDERED).extractHostArray(); checkGetMethods(arr); checkValues(arr); checkToMethods(arr); } }
public void testGetLast() { for (int attempt = 0; attempt < 10; attempt++) { long[] values = generateRandomLongArray(1000, UNORDERED).extractHostArray(); for (LongList list: createLongListVariants(values)) { if (!(list instanceof AbstractLongList)) return; AbstractLongList abstractList = (AbstractLongList)list; for (int j = 0; j < values.length; j++) { assertEquals(abstractList.getLast(j), values[values.length - j - 1]); } } } }
public void testToNativeArray() { int attemptsCount = 5, length = 25; for (int attempt = 0; attempt < attemptsCount; attempt++) { long[] values = generateRandomLongArray(length, UNORDERED).extractHostArray(); for (T list : createLongListVariants(values)) { for (int startIdx = 0; startIdx < length; startIdx++) { for(int endIdx = startIdx + 1; endIdx < length; endIdx++) { long[] expected = LongCollections.repeat(-1, length).toNativeArray(); long[] actual = Arrays.copyOf(expected, expected.length); int len = endIdx - startIdx; System.arraycopy(values, startIdx, expected, startIdx, len); list.toNativeArray(startIdx, actual, startIdx, len); CHECK.order(actual, expected); } } } } }
public void testValues() { checkValues(); checkValues(0, 2, 4, 6, 8); checkValues(0, 10, 10, 20); checkValues(0, 10, 9); checkValues(Integer.MIN_VALUE, 10, 20, 40, Integer.MAX_VALUE); int attemptsCount = 10; int size = 100; for (int attempt = 0; attempt < attemptsCount; attempt++) { checkValues(generateRandomLongArray(size, UNORDERED).extractHostArray()); } }
public void testGet() { for (int attempt = 0; attempt < 10; attempt++) { long[] values = generateRandomLongArray(1000, UNORDERED).extractHostArray(); for (LongList list: createLongListVariants(values)) { if (!(list instanceof AbstractLongList)) return; IntArray indices = generateRandomIntArray(100, UNORDERED, 0, 1000); AbstractLongList abstractList = (AbstractLongList)list; LongList actual = abstractList.get(indices); for (int j = 0; j < actual.size(); j++) { assertEquals(abstractList.get(indices.get(j)), actual.get(j)); } } } }