mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fixes String.indexOf(String) issue
This commit is contained in:
parent
3b2ec91d20
commit
abc6c83827
|
@ -307,7 +307,7 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
|||
public int indexOf(TString str, int fromIndex) {
|
||||
int toIndex = length() - str.length();
|
||||
outer:
|
||||
for (int i = fromIndex; i < toIndex; ++i) {
|
||||
for (int i = fromIndex; i <= toIndex; ++i) {
|
||||
for (int j = 0; j < str.length(); ++j) {
|
||||
if (charAt(i + j) != str.charAt(j)) {
|
||||
continue outer;
|
||||
|
|
|
@ -160,6 +160,7 @@ public class StringTest {
|
|||
@Test
|
||||
public void findsString() {
|
||||
assertEquals(1, "abcdbcd".indexOf("bc"));
|
||||
assertEquals(3, "abcdbcd".indexOf("dbcd"));
|
||||
assertEquals(-1, "abcdbcd".indexOf("bb"));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user