use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class StringJoinerTest method addCharSequenceWithEmptyValue.
public void addCharSequenceWithEmptyValue() {
StringJoiner sj = new StringJoiner(",").setEmptyValue(EMPTY);
CharSequence cs_one = ONE;
CharSequence cs_two = TWO;
sj.add(cs_one);
sj.add(cs_two);
assertEquals(sj.toString(), ONE + "," + TWO);
sj = new StringJoiner(DASH, "{", "}");
sj.add(cs_one);
sj.add(cs_two);
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}");
sj = new StringJoiner(DASH, "{", "}");
assertEquals(sj.toString(), "{}");
sj = new StringJoiner("=", "{", "}").setEmptyValue("");
assertEquals(sj.toString(), "");
sj = new StringJoiner(DASH, "{", "}").setEmptyValue(EMPTY);
assertEquals(sj.toString(), EMPTY);
sj.add(cs_one);
sj.add(cs_two);
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}");
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class StringJoinerTest method noAddAndEmptyValue.
public void noAddAndEmptyValue() {
StringJoiner sj = new StringJoiner(DASH, "", "").setEmptyValue(EMPTY);
assertEquals(sj.toString(), EMPTY);
sj = new StringJoiner(DASH, "<..", "");
assertEquals(sj.toString(), "<..");
sj = new StringJoiner(DASH, "<..", "");
assertEquals(sj.toString(), "<..");
sj = new StringJoiner(DASH, "", "==>");
assertEquals(sj.toString(), "==>");
sj = new StringJoiner(DASH, "{", "}");
assertEquals(sj.toString(), "{}");
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class StringJoinerTest method stringFromtoStringWithEmptyValue.
public void stringFromtoStringWithEmptyValue() {
StringJoiner sj = new StringJoiner(" ", "", "");
assertEquals(sj.toString(), "");
sj = new StringJoiner(", ");
assertEquals(sj.toString(), "");
sj = new StringJoiner(",", "{", "}");
assertEquals(sj.toString(), "{}");
sj = new StringJoiner(",", "{", "}").setEmptyValue("");
assertEquals(sj.toString(), "");
sj = new StringJoiner(",");
sj.add(ONE);
assertEquals(sj.toString(), ONE);
sj.add(TWO);
assertEquals(sj.toString(), ONE + "," + TWO);
sj = new StringJoiner(",", "{--", "--}");
sj.add(ONE);
assertEquals(sj.toString(), "{--" + ONE + "--}");
sj.add(TWO);
assertEquals(sj.toString(), "{--" + ONE + "," + TWO + "--}");
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class StringJoinerTest method addString.
public void addString() {
StringJoiner sj = new StringJoiner(DASH);
sj.add(ONE);
assertEquals(sj.toString(), ONE);
sj = new StringJoiner(DASH, "{", "}");
sj.add(ONE);
assertEquals(sj.toString(), "{" + ONE + "}");
sj.add(TWO);
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}");
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class StringJoinerTest method toStringWithCustomEmptyValue.
public void toStringWithCustomEmptyValue() {
StringJoiner sj = new StringJoiner(DASH, "<", ">").setEmptyValue(EMPTY);
assertEquals(sj.toString(), EMPTY);
sj.add("");
assertEquals(sj.toString(), "<>");
sj.add("");
assertEquals(sj.toString(), "<->");
}
Aggregations