Commit 7dbe70dc authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '2.0.x' into 2.1.x

parents 65e7dbe5 1944954d
......@@ -111,12 +111,14 @@ final class StringSequence implements CharSequence {
if (this == obj) {
return true;
}
if (obj == null || !CharSequence.class.isInstance(obj)) {
if (!(obj instanceof CharSequence)) {
return false;
}
CharSequence other = (CharSequence) obj;
int n = length();
if (n == other.length()) {
if (n != other.length()) {
return false;
}
int i = 0;
while (n-- != 0) {
if (charAt(i) != other.charAt(i)) {
......@@ -126,8 +128,6 @@ final class StringSequence implements CharSequence {
}
return true;
}
return true;
}
@Override
public int hashCode() {
......
......@@ -162,6 +162,13 @@ public class StringSequenceTests {
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
public void startsWithWhenExactMatch() {
assertThat(new StringSequence("abc").startsWith("abc")).isTrue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment