Browse Source

Polish contribution

See gh-24428
pull/24476/head
Sam Brannen 5 years ago
parent
commit
cf9a052e3a
  1. 28
      spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

28
spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java

@ -797,6 +797,20 @@ class ObjectUtilsTests { @@ -797,6 +797,20 @@ class ObjectUtilsTests {
assertThat(ObjectUtils.containsConstant(Tropes.values(), "foo", true)).isFalse();
}
@Test
void containsElement() {
Object[] array = {"foo", "bar", 42, new String[] {"baz", "quux"}};
assertThat(ObjectUtils.containsElement(null, "foo")).isFalse();
assertThat(ObjectUtils.containsElement(array, null)).isFalse();
assertThat(ObjectUtils.containsElement(array, "bogus")).isFalse();
assertThat(ObjectUtils.containsElement(array, "foo")).isTrue();
assertThat(ObjectUtils.containsElement(array, "bar")).isTrue();
assertThat(ObjectUtils.containsElement(array, 42)).isTrue();
assertThat(ObjectUtils.containsElement(array, new String[] {"baz", "quux"})).isTrue();
}
@Test
void caseInsensitiveValueOf() {
assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "foo")).isEqualTo(Tropes.FOO);
@ -807,20 +821,6 @@ class ObjectUtilsTests { @@ -807,20 +821,6 @@ class ObjectUtilsTests {
.withMessage("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes");
}
@Test
void containsElement() {
String keyObject = "key";
String[] array = {"foo", "bar", "Bar", keyObject};
String fakeObject = "fake";
assertThat(ObjectUtils.containsElement(null, keyObject)).isFalse();
assertThat(ObjectUtils.containsElement(array, keyObject)).isTrue();
assertThat(ObjectUtils.containsElement(array, fakeObject)).isFalse();
}
private void assertEqualHashCodes(int expected, Object array) {
int actual = ObjectUtils.nullSafeHashCode(array);
assertThat(actual).isEqualTo(expected);

Loading…
Cancel
Save