From b02e9baeb8269a4f2c1627cadcfe211527bc132f Mon Sep 17 00:00:00 2001 From: xaos Date: Fri, 21 Nov 2014 21:24:24 +0500 Subject: [PATCH] Fix bug in AbstractStringBuilder.delete --- .../teavm/classlib/java/lang/TAbstractStringBuilder.java | 2 +- .../org/teavm/classlib/java/lang/StringBuilderTest.java | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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();