From cf9a052e3a8637d72f281ac0242d34faaae0bd1c Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 3 Feb 2020 15:39:00 +0100 Subject: [PATCH] Polish contribution See gh-24428 --- .../util/ObjectUtilsTests.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java index 7e239d1cc9..aa6cf35811 100644 --- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java @@ -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 { .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);