Search in sources :

Example 66 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistAddWithIndexOutOfRange.

@Test(expected = IndexOutOfBoundsException.class)
public void sublistAddWithIndexOutOfRange() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonInt value = SYSTEM.newInt(99);
    sublist.add(4, value);
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 67 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistRemoveAll.

@Test
public void sublistRemoveAll() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final List<IonValue> toRemove = Arrays.asList(sequence.get(2), sequence.get(3));
    assertTrue(sublist.removeAll(toRemove));
    assertEquals(1, sublist.size());
    for (IonValue v : toRemove) {
        assertFalse(sublist.contains(v));
    }
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 68 with IonSequence

use of com.amazon.ion.IonSequence in project ion-java by amzn.

the class BaseIonSequenceLiteSublistTestCase method sublistRemoveIndexOutOfRange.

@Test(expected = IndexOutOfBoundsException.class)
public void sublistRemoveIndexOutOfRange() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sublist.remove(3);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Aggregations

IonSequence (com.amazon.ion.IonSequence)68 Test (org.junit.Test)62 IonValue (com.amazon.ion.IonValue)61 IonInt (com.amazon.ion.IonInt)17 IonStruct (com.amazon.ion.IonStruct)5 IonLob (com.amazon.ion.IonLob)3 IonType (com.amazon.ion.IonType)3 SymbolToken (com.amazon.ion.SymbolToken)2 ArrayList (java.util.ArrayList)2 IonBool (com.amazon.ion.IonBool)1 IonDatagram (com.amazon.ion.IonDatagram)1 IonException (com.amazon.ion.IonException)1 IonFloat (com.amazon.ion.IonFloat)1 IonSymbol (com.amazon.ion.IonSymbol)1 IonText (com.amazon.ion.IonText)1 IonTimestamp (com.amazon.ion.IonTimestamp)1 SymbolTable (com.amazon.ion.SymbolTable)1 IOException (java.io.IOException)1