Test ObjectUtils.containsElement()
This commit introduces a unit test for the containsElement() method in ObjectUtils. Closes gh-24428
This commit is contained in:
parent
14a32d13d0
commit
1b39f138eb
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -37,6 +37,7 @@ import static org.springframework.util.ObjectUtils.isEmpty;
|
|||
* @author Juergen Hoeller
|
||||
* @author Rick Evans
|
||||
* @author Sam Brannen
|
||||
* @author Hyunjin Choi
|
||||
*/
|
||||
class ObjectUtilsTests {
|
||||
|
||||
|
|
@ -806,6 +807,20 @@ 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…
Reference in New Issue