Search in sources :

Example 46 with IonSequence

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);
}
Also used : IonValue(com.amazon.ion.IonValue) IonInt(com.amazon.ion.IonInt) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 47 with IonSequence

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());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 48 with IonSequence

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));
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 49 with IonSequence

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());
}
Also used : IonValue(com.amazon.ion.IonValue) IonSequence(com.amazon.ion.IonSequence) Test(org.junit.Test)

Example 50 with IonSequence

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());
}
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