Fix asymmetry of equals when element has trailing dashes
See gh-34804
This commit is contained in:
committed by
Andy Wilkinson
parent
7b565bd397
commit
a86429a62a
@@ -406,7 +406,7 @@ public final class ConfigurationPropertyName implements Comparable<Configuration
|
||||
int i2 = 0;
|
||||
while (i1 < l1) {
|
||||
if (i2 >= l2) {
|
||||
return false;
|
||||
return remainderIsNotAlphanumeric(e1, i, i1);
|
||||
}
|
||||
char ch1 = e1.charAt(i, i1);
|
||||
char ch2 = e2.charAt(i, i2);
|
||||
|
||||
@@ -702,6 +702,14 @@ class ConfigurationPropertyNameTests {
|
||||
assertThat(name2).isEqualTo(name1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void equalsSymmetricWhenNameMatchesDueToRemovalOfTrailingDashes() {
|
||||
ConfigurationPropertyName n1 = ConfigurationPropertyName.of("foobar");
|
||||
ConfigurationPropertyName n2 = ConfigurationPropertyName.of("foobar--");
|
||||
assertThat(n1).isEqualTo(n2);
|
||||
assertThat(n2).isEqualTo(n1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void isValidWhenValidShouldReturnTrue() {
|
||||
assertThat(ConfigurationPropertyName.isValid("")).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user