Merge branch '2.1.x'
This commit is contained in:
commit
317c4c2c38
|
@ -111,20 +111,20 @@ final class StringSequence implements CharSequence {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null || !CharSequence.class.isInstance(obj)) {
|
if (!(obj instanceof CharSequence)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CharSequence other = (CharSequence) obj;
|
CharSequence other = (CharSequence) obj;
|
||||||
int n = length();
|
int n = length();
|
||||||
if (n == other.length()) {
|
if (n != other.length()) {
|
||||||
int i = 0;
|
return false;
|
||||||
while (n-- != 0) {
|
}
|
||||||
if (charAt(i) != other.charAt(i)) {
|
int i = 0;
|
||||||
return false;
|
while (n-- != 0) {
|
||||||
}
|
if (charAt(i) != other.charAt(i)) {
|
||||||
i++;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
i++;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,13 @@ public class StringSequenceTests {
|
||||||
assertThat(a).isEqualTo(b).isNotEqualTo(c);
|
assertThat(a).isEqualTo(b).isNotEqualTo(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void notEqualsWhenSequencesOfDifferentLength() {
|
||||||
|
StringSequence a = new StringSequence("abcd");
|
||||||
|
StringSequence b = new StringSequence("ef");
|
||||||
|
assertThat(a).isNotEqualTo(b);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void startsWithWhenExactMatch() {
|
public void startsWithWhenExactMatch() {
|
||||||
assertThat(new StringSequence("abc").startsWith("abc")).isTrue();
|
assertThat(new StringSequence("abc").startsWith("abc")).isTrue();
|
||||||
|
|
Loading…
Reference in New Issue