Search in sources :

Example 21 with IonSequence

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

the class BaseIonSequenceLiteSublistTestCase method subListToIndexExceedsSize.

@Test(expected = IndexOutOfBoundsException.class)
public void subListToIndexExceedsSize() {
    IonSequence seq = newSequence();
    // toIndex is exclusive, hence the + 1
    seq.subList(0, seq.size() + 1);
}
Also used : IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 22 with IonSequence

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

the class BaseIonSequenceLiteSublistTestCase method sublistContains.

@Test
public void sublistContains() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final IonValue insideSubList = sequence.get(2);
    final IonValue outsideSublist = sequence.get(0);
    assertTrue(sublist.contains(insideSubList));
    assertFalse(sublist.contains(outsideSublist));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 23 with IonSequence

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

the class BaseIonSequenceLiteSublistTestCase method sublistAddAllWithIndex.

@Test
public void sublistAddAllWithIndex() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    final List<IonInt> values = Arrays.asList(SYSTEM.newInt(100), SYSTEM.newInt(101));
    sublist.addAll(0, values);
    assertEquals(5, sublist.size());
    assertEquals(values.get(0), sublist.get(0));
    assertEquals(values.get(1), sublist.get(1));
    assertEquals(2, ((IonInt) sublist.get(2)).intValue());
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 24 with IonSequence

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

the class BaseIonSequenceLiteSublistTestCase method sublistGetConcurrentModification.

@Test(expected = ConcurrentModificationException.class)
public void sublistGetConcurrentModification() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    sequence.clear();
    sublist.get(0);
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 25 with IonSequence

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

the class BaseIonSequenceLiteSublistTestCase method sublistLastIndexOf.

@Test
public void sublistLastIndexOf() {
    final IonSequence sequence = newSequence();
    final List<IonValue> sublist = sequence.subList(2, 5);
    assertEquals(0, sublist.lastIndexOf(sequence.get(2)));
    assertEquals(-1, sublist.lastIndexOf(sequence.get(0)));
    assertEquals(-1, sublist.lastIndexOf(SYSTEM.newInt(99)));
}
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