use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistSetConcurrentModification.
@Test(expected = ConcurrentModificationException.class)
public void sublistSetConcurrentModification() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
sequence.remove(0);
final IonInt element = SYSTEM.newInt(99);
sublist.set(0, element);
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistToTypedArray.
@Test
public void sublistToTypedArray() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final IonValue[] array = sublist.toArray(IonValue.EMPTY_ARRAY);
assertEquals(3, array.length);
assertEquals(2, ((IonInt) array[0]).intValue());
assertEquals(3, ((IonInt) array[1]).intValue());
assertEquals(4, ((IonInt) array[2]).intValue());
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistContainsAll.
@Test
public void sublistContainsAll() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final List<IonValue> insideSubList = Arrays.asList(sequence.get(2), sequence.get(3));
final List<IonValue> outsideSublist = Arrays.asList(sequence.get(0), sequence.get(1));
final List<IonValue> mixed = Arrays.asList(sequence.get(0), sequence.get(3));
assertTrue(sublist.containsAll(insideSubList));
assertFalse(sublist.containsAll(outsideSublist));
assertFalse(sublist.containsAll(mixed));
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistRetainAll.
@Test
public void sublistRetainAll() {
final IonSequence sequence = newSequence();
final List<IonValue> sublist = sequence.subList(2, 5);
final List<IonValue> toRetain = Collections.singletonList(sublist.get(0));
assertTrue(sublist.retainAll(toRetain));
assertEquals(1, sublist.size());
assertTrue(sublist.contains(toRetain.get(0)));
assertEquals(5, sequence.size());
}
use of com.amazon.ion.IonSequence in project ion-java by amzn.
the class BaseIonSequenceLiteSublistTestCase method sublistSize.
@Test
public void sublistSize() {
final IonSequence sequence = newSequence();
final List<IonValue> actual = sequence.subList(2, 5);
assertEquals(3, actual.size());
}
Aggregations