Fix bug in AbstractStringBuilder.delete

This commit is contained in:
xaos 2014-11-21 21:24:24 +05:00
parent 19c18a41c5
commit b02e9baeb8
2 changed files with 8 additions and 1 deletions

View File

@ -693,7 +693,7 @@ class TAbstractStringBuilder extends TObject implements TSerializable, TCharSequ
} }
public TAbstractStringBuilder delete(int start, int end) { public TAbstractStringBuilder delete(int start, int end) {
if (start > end || start >= length) { if (start > end || start > length) {
throw new TStringIndexOutOfBoundsException(); throw new TStringIndexOutOfBoundsException();
} }
if (start == end) { if (start == end) {

View File

@ -310,6 +310,13 @@ public class StringBuilderTest {
assertEquals('9', sb.charAt(7)); assertEquals('9', sb.charAt(7));
} }
@Test
public void deletesNothing() {
StringBuilder sb = new StringBuilder();
sb.delete(0, 0);
assertEquals(0, sb.length());
}
@Test @Test
public void replacesRangeWithSequenceOfSameLength() { public void replacesRangeWithSequenceOfSameLength() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();