Merge pull request #36 from drxaos/master

Fix bug in AbstractStringBuilder.delete
This commit is contained in:
Alexey Andreev 2014-11-21 19:38:51 +03:00
commit 2322a97d4c
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) {
if (start > end || start >= length) {
if (start > end || start > length) {
throw new TStringIndexOutOfBoundsException();
}
if (start == end) {

View File

@ -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();