Search in sources :

Example 1 with ImmutableIntList

use of org.eclipse.collections.api.list.primitive.ImmutableIntList in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toImmutableIntList.

@Test
public void toImmutableIntList() {
    ImmutableIntList list = PrimitiveStreams.iIntList(IntStream.rangeClosed(1, 10));
    Assert.assertEquals(IntInterval.oneTo(10), list);
    Assert.assertEquals(IntLists.mutable.ofAll(IntStream.rangeClosed(1, 10)), list);
}
Also used : ImmutableIntList(org.eclipse.collections.api.list.primitive.ImmutableIntList) Test(org.junit.Test)

Example 2 with ImmutableIntList

use of org.eclipse.collections.api.list.primitive.ImmutableIntList in project eclipse-collections by eclipse.

the class CodePointAdapterTest method makeString.

@Override
@Test
public void makeString() {
    ImmutableIntList list = this.classUnderTest();
    StringBuilder expectedString = new StringBuilder("");
    StringBuilder expectedString1 = new StringBuilder("");
    int size = list.size();
    for (int each = 0; each < size; each++) {
        expectedString.appendCodePoint(each + 1);
        expectedString1.appendCodePoint(each + 1);
        expectedString.append(each == size - 1 ? "" : ", ");
        expectedString1.append(each == size - 1 ? "" : "/");
    }
    Assert.assertEquals(expectedString.toString(), list.makeString());
    Assert.assertEquals(expectedString1.toString(), list.makeString("/"));
}
Also used : ImmutableIntList(org.eclipse.collections.api.list.primitive.ImmutableIntList) Test(org.junit.Test)

Example 3 with ImmutableIntList

use of org.eclipse.collections.api.list.primitive.ImmutableIntList in project eclipse-collections by eclipse.

the class CodePointAdapterTest method appendStringStringBuffer.

@SuppressWarnings("StringBufferMayBeStringBuilder")
@Test
public void appendStringStringBuffer() {
    StringBuffer expectedString = new StringBuffer("");
    StringBuffer expectedString1 = new StringBuffer("");
    int size = this.classUnderTest().size();
    for (int each = 0; each < size; each++) {
        expectedString.appendCodePoint(each + 1);
        expectedString1.appendCodePoint(each + 1);
        expectedString.append(each == size - 1 ? "" : ", ");
        expectedString1.append(each == size - 1 ? "" : "/");
    }
    ImmutableIntList list = this.classUnderTest();
    StringBuffer appendable2 = new StringBuffer();
    list.appendString(appendable2);
    Assert.assertEquals(expectedString.toString(), appendable2.toString());
    StringBuffer appendable3 = new StringBuffer();
    list.appendString(appendable3, "/");
    Assert.assertEquals(expectedString1.toString(), appendable3.toString());
    StringBuffer appendable4 = new StringBuffer();
    this.classUnderTest().appendString(appendable4, "", "", "");
    Assert.assertEquals(this.classUnderTest().toString(), appendable4.toString());
}
Also used : ImmutableIntList(org.eclipse.collections.api.list.primitive.ImmutableIntList) Test(org.junit.Test)

Example 4 with ImmutableIntList

use of org.eclipse.collections.api.list.primitive.ImmutableIntList in project eclipse-collections by eclipse.

the class CodePointAdapterTest method testEquals.

@Override
@Test
public void testEquals() {
    super.testEquals();
    ImmutableIntList list1 = this.newWith(1, 2, 3, 4);
    ImmutableIntList list2 = this.newWith(4, 3, 2, 1);
    Assert.assertNotEquals(list1, list2);
    Assert.assertEquals(CodePointAdapter.adapt(UNICODE_STRING), CodePointAdapter.adapt(UNICODE_STRING));
    Assert.assertNotEquals(CodePointAdapter.adapt("\u3042\uD840\uDC00\u3044\uD840\uDC03\u3046"), CodePointAdapter.adapt(UNICODE_STRING));
    Assert.assertEquals(CodePointAdapter.adapt("ABC"), CodePointAdapter.adapt("ABC"));
    Assert.assertNotEquals(CodePointAdapter.adapt("123"), CodePointAdapter.adapt("ABC"));
    Verify.assertEqualsAndHashCode(CodePointAdapter.adapt("ABC"), CodePointList.from("ABC"));
    Verify.assertEqualsAndHashCode(CodePointAdapter.adapt(UNICODE_STRING), CodePointList.from(UNICODE_STRING));
    Assert.assertNotEquals(CodePointList.from("123"), CodePointAdapter.adapt("ABC"));
    Assert.assertNotEquals(CodePointAdapter.adapt("ABC"), CodePointList.from("123"));
    Assert.assertNotEquals(CodePointList.from("ABCD"), CodePointAdapter.adapt("ABC"));
    Assert.assertNotEquals(CodePointAdapter.adapt("ABC"), CodePointList.from("ABCD"));
    Assert.assertNotEquals(CodePointList.from("ABC"), CodePointAdapter.adapt("ABCD"));
    Assert.assertNotEquals(CodePointAdapter.adapt("ABCD"), CodePointList.from("ABC"));
}
Also used : ImmutableIntList(org.eclipse.collections.api.list.primitive.ImmutableIntList) Test(org.junit.Test)

Example 5 with ImmutableIntList

use of org.eclipse.collections.api.list.primitive.ImmutableIntList in project eclipse-collections by eclipse.

the class CodePointListTest method appendString.

@Override
@Test
public void appendString() {
    StringBuilder expectedString = new StringBuilder("");
    StringBuilder expectedString1 = new StringBuilder("");
    int size = this.classUnderTest().size();
    for (int each = 0; each < size; each++) {
        expectedString.appendCodePoint(each + 1);
        expectedString1.appendCodePoint(each + 1);
        expectedString.append(each == size - 1 ? "" : ", ");
        expectedString1.append(each == size - 1 ? "" : "/");
    }
    ImmutableIntList list = this.classUnderTest();
    StringBuilder appendable2 = new StringBuilder();
    list.appendString(appendable2);
    Assert.assertEquals(expectedString.toString(), appendable2.toString());
    StringBuilder appendable3 = new StringBuilder();
    list.appendString(appendable3, "/");
    Assert.assertEquals(expectedString1.toString(), appendable3.toString());
    StringBuilder appendable4 = new StringBuilder();
    this.classUnderTest().appendString(appendable4, "", "", "");
    Assert.assertEquals(this.classUnderTest().toString(), appendable4.toString());
}
Also used : ImmutableIntList(org.eclipse.collections.api.list.primitive.ImmutableIntList) Test(org.junit.Test)

Aggregations

ImmutableIntList (org.eclipse.collections.api.list.primitive.ImmutableIntList)10 Test (org.junit.Test)10