use of java.util.AbstractList in project robovm by robovm.
the class ConcurrentModTest method testAdd.
/*
* Test method for 'java.util.AbstractList.subList(int, int)'
*/
public void testAdd() {
AbstractList al = new ArrayList();
Double one = new Double(1.0);
Double two = new Double(2.0);
Double three = new Double(3.0);
Double four = new Double(4.0);
al.add(one);
al.add(two);
al.add(three);
al.add(four);
List sub = al.subList(1, 3);
assertEquals(2, sub.size());
// the sub.get(1) is 3.0
assertTrue(((Double) sub.get(1)).doubleValue() <= 3.0);
assertTrue(((Double) sub.get(1)).doubleValue() > 2.0);
// remove the 2.0
al.remove(1);
try {
// illegal call the subList's method Add(int,Object).
sub.add(1, two);
fail("It should throws ConcurrentModificationException.");
} catch (ConcurrentModificationException e) {
return;
}
}
use of java.util.AbstractList in project robovm by robovm.
the class AbstractListTest method test_listIteratorI.
public void test_listIteratorI() {
AbstractList al1 = new ArrayList();
AbstractList al2 = new ArrayList();
al1.add(0);
al1.add(1);
al1.add(2);
al1.add(3);
al1.add(4);
al2.add(2);
al2.add(3);
al2.add(4);
Iterator li1 = al1.listIterator(2);
Iterator li2 = al2.listIterator();
while (li1.hasNext() && li2.hasNext()) {
assertEquals(li1.next(), li2.next());
}
assertSame(li1.hasNext(), li2.hasNext());
try {
al1.listIterator(-1);
fail("IndexOutOfBoundsException expected");
} catch (IndexOutOfBoundsException ee) {
//expected
}
try {
al1.listIterator(al1.size() + 1);
fail("IndexOutOfBoundsException expected");
} catch (IndexOutOfBoundsException ee) {
//expected
}
}
use of java.util.AbstractList in project robovm by robovm.
the class AbstractListTest method test_indexOfLjava_lang_Object.
public void test_indexOfLjava_lang_Object() {
AbstractList al = new ArrayList();
al.add(0);
al.add(1);
al.add(2);
al.add(3);
al.add(4);
assertEquals(-1, al.indexOf(5));
assertEquals(2, al.indexOf(2));
}
use of java.util.AbstractList in project robovm by robovm.
the class AbstractListTest method test_subListII.
/**
* java.util.AbstractList#subList(int, int)
*/
public void test_subListII() {
// Test each of the SubList operations to ensure a
// ConcurrentModificationException does not occur on an AbstractList
// which does not update modCount
SimpleList mList = new SimpleList();
mList.add(new Object());
mList.add(new Object());
List sList = mList.subList(0, 2);
// calls add(int, Object)
sList.add(new Object());
sList.get(0);
sList.add(0, new Object());
sList.get(0);
sList.addAll(Arrays.asList(new String[] { "1", "2" }));
sList.get(0);
sList.addAll(0, Arrays.asList(new String[] { "3", "4" }));
sList.get(0);
sList.remove(0);
sList.get(0);
ListIterator lit = sList.listIterator();
lit.add(new Object());
lit.next();
lit.remove();
lit.next();
// calls removeRange()
sList.clear();
sList.add(new Object());
// test the type of sublist that is returned
List al = new ArrayList();
for (int i = 0; i < 10; i++) {
al.add(new Integer(i));
}
assertTrue("Sublist returned should have implemented Random Access interface", al.subList(3, 7) instanceof RandomAccess);
List ll = new LinkedList();
for (int i = 0; i < 10; i++) {
ll.add(new Integer(i));
}
assertTrue("Sublist returned should not have implemented Random Access interface", !(ll.subList(3, 7) instanceof RandomAccess));
}
use of java.util.AbstractList in project xtext-xtend by eclipse.
the class GetSuperTypeBenchmark method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
typeReference = getTypeReference(type);
TypeReferences typeReferences = typeReference.getOwner().getServices().getTypeReferences();
abstractCollection = typeReferences.findDeclaredType(AbstractCollection.class, typeReference.getType());
abstractList = typeReferences.findDeclaredType(AbstractList.class, typeReference.getType());
collection = typeReferences.findDeclaredType(Collection.class, typeReference.getType());
iterable = typeReferences.findDeclaredType(Iterable.class, typeReference.getType());
list = typeReferences.findDeclaredType(List.class, typeReference.getType());
object = typeReferences.findDeclaredType(Object.class, typeReference.getType());
set = typeReferences.findDeclaredType(Set.class, typeReference.getType());
stringBuilder = typeReferences.findDeclaredType(StringBuilder.class, typeReference.getType());
EcoreUtil.resolveAll(typeReference.getOwner().getContextResourceSet());
}
Aggregations