mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -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) {
|
for (CharSequence element : elements) {
|
||||||
resultLength += element.length();
|
resultLength += element.length();
|
||||||
}
|
}
|
||||||
resultLength += elements.length * delimiter.length();
|
resultLength += (elements.length - 1) * delimiter.length();
|
||||||
|
|
||||||
char[] chars = new char[resultLength];
|
char[] chars = new char[resultLength];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
|
@ -290,4 +290,25 @@ public class StringTest {
|
||||||
public void internsConstants() {
|
public void internsConstants() {
|
||||||
assertSame("abc", ("a" + "bc").intern());
|
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