mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-23 00:24:11 -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) {
|
public int indexOf(TString str, int fromIndex) {
|
||||||
int toIndex = length() - str.length();
|
int toIndex = length() - str.length();
|
||||||
outer:
|
outer:
|
||||||
for (int i = fromIndex; i < toIndex; ++i) {
|
for (int i = fromIndex; i <= toIndex; ++i) {
|
||||||
for (int j = 0; j < str.length(); ++j) {
|
for (int j = 0; j < str.length(); ++j) {
|
||||||
if (charAt(i + j) != str.charAt(j)) {
|
if (charAt(i + j) != str.charAt(j)) {
|
||||||
continue outer;
|
continue outer;
|
||||||
|
|
|
@ -160,6 +160,7 @@ public class StringTest {
|
||||||
@Test
|
@Test
|
||||||
public void findsString() {
|
public void findsString() {
|
||||||
assertEquals(1, "abcdbcd".indexOf("bc"));
|
assertEquals(1, "abcdbcd".indexOf("bc"));
|
||||||
|
assertEquals(3, "abcdbcd".indexOf("dbcd"));
|
||||||
assertEquals(-1, "abcdbcd".indexOf("bb"));
|
assertEquals(-1, "abcdbcd".indexOf("bb"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user