@Test public void testNonEmpty() { final int N = 2000; PackedArray a = packedArray(); for (int size = 1; size <= N; size++) { Element e = new Element(size); a.append(e); } for (int size = 1; size <= N; size++) { Element e = new Element(); a.at(size - 1, e); assertEquals(size, e.size()); } }
@Test public void testRandom() { final int N = 10000; Random random = new Random(); for (int t = 0; t < 100; t++) { PackedArray a = packedArray(); int[] sizes = new int[N]; for (int i = 0; i < N; i++) { int size = 10 + random.nextInt(500); Element e = new Element(size); a.append(e); sizes[i] = size; } for (int i = 0; i < N; i++) { int size = sizes[i]; Element e = new Element(); a.at(i, e); assertEquals(size, e.size()); } } }