add methods

This commit is contained in:
Looly
2022-02-27 00:08:59 +08:00
parent c46781f2eb
commit ce62b5e792
4 changed files with 75 additions and 15 deletions

View File

@@ -78,4 +78,25 @@ public class StrJoinerTest {
.append("3");
Assert.assertEquals("[1],[2],[3]", append.toString());
}
@Test
public void lengthTest(){
StrJoiner joiner = StrJoiner.of(",", "[", "]");
Assert.assertEquals(joiner.toString().length(), joiner.length());
joiner.append("123");
Assert.assertEquals(joiner.toString().length(), joiner.length());
}
@Test
public void mergeTest(){
StrJoiner joiner1 = StrJoiner.of(",", "[", "]");
joiner1.append("123");
StrJoiner joiner2 = StrJoiner.of(",", "[", "]");
joiner1.append("456");
joiner1.append("789");
final StrJoiner merge = joiner1.merge(joiner2);
Assert.assertEquals("[123,456,789]", merge.toString());
}
}