@Test public void testWithMethods() { Verify.assertContainsAll(ArrayListAdapter.newList().with(1), 1); Verify.assertContainsAll(ArrayListAdapter.newList().with(1, 2), 1, 2); Verify.assertContainsAll(ArrayListAdapter.newList().with(1, 2, 3), 1, 2, 3); Verify.assertContainsAll(ArrayListAdapter.newList().with(1, 2, 3, 4), 1, 2, 3, 4); }
@Override @Test public void newListWithSize() { super.newListWithSize(); MutableList<Integer> objects = ArrayListAdapter.<Integer>newList(4).with(1, 2, 3); Assert.assertEquals(1, objects.indexOf(2)); }
@Test public void testForEachWithIndexWithFromToWithCommandoPatternOptimization() { MutableList<Integer> result2 = Lists.mutable.of(); // Requires list of 100+ elements to engage commando pattern optimization ArrayListAdapter.adapt(new ArrayList<>(Interval.oneTo(200))) .forEachWithIndex(99, 199, new AddToList(result2)); Verify.assertSize(101, result2); }
@Test public void testBAOSSize() { MutableList<Integer> mutableArrayList = ArrayListAdapter.newList(); ByteArrayOutputStream stream1 = SerializeTestHelper.getByteArrayOutputStream(mutableArrayList); LOGGER.info("ArrayListAdapter size: {}", stream1.size()); LOGGER.info("{}", stream1); Assert.assertTrue(stream1.size() > 0); List<Integer> arrayList = new ArrayList<>(); ByteArrayOutputStream stream2 = SerializeTestHelper.getByteArrayOutputStream(arrayList); LOGGER.info("ArrayList size: {}", stream2.size()); LOGGER.info("{}", stream2); Assert.assertTrue(stream2.size() > 0); }
@Override @Test public void newEmpty() { Verify.assertInstanceOf(ArrayListAdapter.class, ArrayListAdapter.newList().newEmpty()); }
@Override protected <T> ArrayListAdapter<T> newWith(T... littleElements) { return ArrayListAdapter.<T>newList().with(littleElements); }