use of org.eclipse.collections.api.list.primitive.ImmutableCharList in project eclipse-collections by eclipse.
the class CharAdapterTest method makeString.
@Override
@Test
public void makeString() {
ImmutableCharList list = this.classUnderTest();
StringBuilder expectedString = new StringBuilder("");
StringBuilder expectedString1 = new StringBuilder("");
int size = list.size();
for (char each = 0; each < size; each++) {
expectedString.append((char) (each + (char) 1));
expectedString1.append((char) (each + (char) 1));
expectedString.append(each == size - 1 ? "" : ", ");
expectedString1.append(each == size - 1 ? "" : "/");
}
Assert.assertEquals(expectedString.toString(), list.makeString());
Assert.assertEquals(expectedString1.toString(), list.makeString("/"));
}
use of org.eclipse.collections.api.list.primitive.ImmutableCharList in project eclipse-collections by eclipse.
the class StringIterateTest method asCharAdapter.
@Test
public void asCharAdapter() {
CharAdapter answer = StringIterate.asCharAdapter("HelloHellow").collectChar(Character::toUpperCase).select(c -> c != 'W').distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).newWith('!');
Assert.assertEquals("OH!", answer.toString());
Assert.assertEquals("OH!", answer.toStringBuilder().toString());
Assert.assertEquals("OH!", answer.makeString(""));
CharList charList = StringIterate.asCharAdapter("HelloHellow").asLazy().collectChar(Character::toUpperCase).select(c -> c != 'W').toList().distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).with('!');
Assert.assertEquals("OH!", CharAdapter.from(charList).toString());
Assert.assertEquals("OH!", CharAdapter.from(CharAdapter.from(charList)).toString());
String helloUppercase2 = StringIterate.asCharAdapter("Hello").asLazy().collectChar(Character::toUpperCase).makeString("");
Assert.assertEquals("HELLO", helloUppercase2);
CharArrayList arraylist = new CharArrayList();
StringIterate.asCharAdapter("Hello".toUpperCase()).chars().sorted().forEach(e -> arraylist.add((char) e));
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arraylist);
ImmutableCharList arrayList2 = StringIterate.asCharAdapter("Hello".toUpperCase()).toSortedList().toImmutable();
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arrayList2);
Assert.assertEquals(StringIterate.asCharAdapter("HELLO"), CharAdapter.adapt("hello").collectChar(Character::toUpperCase));
}
use of org.eclipse.collections.api.list.primitive.ImmutableCharList in project eclipse-collections by eclipse.
the class CharAdapterTest method appendString.
@Override
@Test
public void appendString() {
StringBuilder expectedString = new StringBuilder("");
StringBuilder expectedString1 = new StringBuilder("");
int size = this.classUnderTest().size();
for (char each = 0; each < size; each++) {
expectedString.append((char) (each + (char) 1));
expectedString1.append((char) (each + (char) 1));
expectedString.append(each == size - 1 ? "" : ", ");
expectedString1.append(each == size - 1 ? "" : "/");
}
ImmutableCharList 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());
}
Aggregations