mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
fix String#join, rm producing extra zero characters
This commit is contained in:
parent
099b9c5827
commit
74ee848e0c
|
@ -667,7 +667,7 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
|||
for (CharSequence element : elements) {
|
||||
resultLength += element.length();
|
||||
}
|
||||
resultLength += elements.length * delimiter.length();
|
||||
resultLength += (elements.length - 1) * delimiter.length();
|
||||
|
||||
char[] chars = new char[resultLength];
|
||||
int index = 0;
|
||||
|
|
|
@ -290,4 +290,25 @@ public class StringTest {
|
|||
public void internsConstants() {
|
||||
assertSame("abc", ("a" + "bc").intern());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void joinStrings() {
|
||||
String str = String.join("/", "a", "b");
|
||||
assertEquals(3, str.length());
|
||||
assertEquals("a/b", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void joinSingleString() {
|
||||
String str = String.join("/", "a");
|
||||
assertEquals(1, str.length());
|
||||
assertEquals("a", str);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void joinNoStrings() {
|
||||
String str = String.join("/");
|
||||
assertEquals(0, str.length());
|
||||
assertEquals("", str);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user