mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
parent
fcb13b24ad
commit
a40c955d39
|
@ -674,7 +674,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
|
|||
|
||||
public int indexOf(TString str, int fromIndex) {
|
||||
int sz = length - str.length();
|
||||
outer: for (int i = fromIndex; i < sz; ++i) {
|
||||
outer: for (int i = fromIndex; i <= sz; ++i) {
|
||||
for (int j = 0; j < str.length(); ++j) {
|
||||
if (buffer[i + j] != str.charAt(j)) {
|
||||
continue outer;
|
||||
|
|
|
@ -407,4 +407,14 @@ public class StringBuilderTest {
|
|||
public void substringWithUpperBoundAtEndWorks() {
|
||||
assertEquals("23", "123".substring(1, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexOf() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("12345");
|
||||
assertEquals(3, sb.indexOf("45"));
|
||||
assertEquals(-1, sb.indexOf("56"));
|
||||
assertEquals(0, sb.indexOf("12345"));
|
||||
assertEquals(0, sb.indexOf("123"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user