diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java index 72314d460..9c81a0eb3 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TAbstractStringBuilder.java @@ -693,7 +693,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ } public TAbstractStringBuilder delete(int start, int end) { - if (start > end || start >= length) { + if (start > end || start > length) { throw new TStringIndexOutOfBoundsException(); } if (start == end) { diff --git a/teavm-classlib/src/test/java/org/teavm/classlib/java/lang/StringBuilderTest.java b/teavm-classlib/src/test/java/org/teavm/classlib/java/lang/StringBuilderTest.java index 2aa07ca1c..df50934c8 100644 --- a/teavm-classlib/src/test/java/org/teavm/classlib/java/lang/StringBuilderTest.java +++ b/teavm-classlib/src/test/java/org/teavm/classlib/java/lang/StringBuilderTest.java @@ -310,6 +310,13 @@ public class StringBuilderTest { assertEquals('9', sb.charAt(7)); } + @Test + public void deletesNothing() { + StringBuilder sb = new StringBuilder(); + sb.delete(0, 0); + assertEquals(0, sb.length()); + } + @Test public void replacesRangeWithSequenceOfSameLength() { StringBuilder sb = new StringBuilder();