YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", 10, new YoVariableRegistry("Test")); int currentSize = 10; while (list.size() < currentSize)
@Test(timeout = 30000) public void testConstructor() { YoPreallocatedList<YoDouble> list = new YoPreallocatedList<>(YoDouble.class, "Test", 10, new YoVariableRegistry("Test")); assertTrue(list.isEmpty()); assertTrue(list.size() == 0); assertTrue(list.getLast() == null); }
@Test(timeout = 30000) public void testRemove() YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", 10, new YoVariableRegistry("Test")); int currentSize = 10; while (list.size() < currentSize)
@Test(timeout = 30000) public void testAddAndGet() YoPreallocatedList<YoDouble> list = new YoPreallocatedList<>(YoDouble.class, "Test", 20, new YoVariableRegistry("Test")); ArrayList<YoDouble> expectedList = new ArrayList<>();
@Test(timeout = 30000) public void testRemoveIndex() { int size = 10; YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", size, new YoVariableRegistry("Test")); for (int i = 0; i < size; i++) { list.add().set(i); } assertTrue(list.remove(8).getValue() == 8); assertTrue(list.size() == size - 1); assertTrue(list.remove(4).getValue() == 4); assertTrue(list.size() == size - 2); assertTrue(list.remove(2).getValue() == 2); assertTrue(list.size() == size - 3); assertTrue(list.remove(size - 4).getValue() == size - 1); assertTrue(list.size() == size - 4); }
YoDouble testDouble = new YoDouble("Test", testRegistry); YoPreallocatedList<YoDouble> list = new YoPreallocatedList<>(YoDouble.class, "Test", 10, testRegistry); for (int i = 0; i < size; i++)
@Test(timeout = 30000) public void testSort() { YoPreallocatedList<YoInteger> list = new YoPreallocatedList<>(YoInteger.class, "Test", 10, new YoVariableRegistry("Test")); list.add().set(-3); list.add().set(20); list.add().set(-10); list.add().set(19); list.add().set(50); list.sort((o1, o2) -> NumberUtils.compare(o1.getIntegerValue(), o2.getIntegerValue())); assertTrue(list.get(0).getValue() == -10); assertTrue(list.get(1).getValue() == -3); assertTrue(list.get(2).getValue() == 19); assertTrue(list.get(3).getValue() == 20); assertTrue(list.get(4).getValue() == 50); }