use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistSizeConcurrentModification.
// Concurrent modification tests ---------------------------------------------------------------------------------
@Test(expected = ConcurrentModificationException.class)
public void sublistSizeConcurrentModification() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
sequence.add(SYSTEM.newInt(99));
sublist.size();
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistAddConcurrentModification.
@Test(expected = ConcurrentModificationException.class)
public void sublistAddConcurrentModification() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
sequence.remove(0);
sublist.add(SYSTEM.newInt(0));
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistIndexOf.
@Test
public void sublistIndexOf() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
assertEquals(0, sublist.indexOf(sequence.get(2)));
assertEquals(-1, sublist.indexOf(sequence.get(0)));
assertEquals(-1, sublist.indexOf(SYSTEM.newInt(99)));
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistIterator.
@Test
public void sublistIterator() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final Iterator<IonValue> iterator = sublist.iterator();
assertTrue(iterator.hasNext());
assertEquals(sublist.get(0), iterator.next());
assertTrue(iterator.hasNext());
assertEquals(sublist.get(1), iterator.next());
assertTrue(iterator.hasNext());
assertEquals(sublist.get(2), iterator.next());
assertFalse(iterator.hasNext());
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistListIterator.
@Test
public void sublistListIterator() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final ListIterator<IonValue> iterator = sublist.listIterator();
assertFalse(iterator.hasPrevious());
assertTrue(iterator.hasNext());
assertEquals(0, iterator.nextIndex());
assertEquals(-1, iterator.previousIndex());
assertEquals(sublist.get(0), iterator.next());
assertTrue(iterator.hasNext());
assertTrue(iterator.hasPrevious());
assertEquals(1, iterator.nextIndex());
assertEquals(0, iterator.previousIndex());
assertEquals(sublist.get(1), iterator.next());
assertTrue(iterator.hasNext());
assertTrue(iterator.hasPrevious());
assertEquals(2, iterator.nextIndex());
assertEquals(1, iterator.previousIndex());
assertEquals(sublist.get(2), iterator.next());
assertEquals(3, iterator.nextIndex());
assertEquals(2, iterator.previousIndex());
assertFalse(iterator.hasNext());
assertTrue(iterator.hasPrevious());
assertEquals(sublist.get(2), iterator.previous());
final IonInt newAddValue = SYSTEM.newInt(200);
iterator.add(newAddValue);
assertEquals(newAddValue, sublist.get(2));
assertTrue(iterator.hasNext());
}
Aggregations