1414 */
1515package org .htmlunit .util ;
1616
17+ import static org .junit .jupiter .api .Assertions .assertFalse ;
1718import static org .junit .jupiter .api .Assertions .assertThrows ;
19+ import static org .junit .jupiter .api .Assertions .assertTrue ;
1820
19- import org .htmlunit .SimpleWebTestCase ;
2021import org .junit .jupiter .api .Test ;
2122
2223/**
2324 * Tests for {@link ArrayUtils}.
2425 *
2526 * @author Ronald Brill
2627 */
27- public class ArrayUtilsTest extends SimpleWebTestCase {
28+ public class ArrayUtilsTest {
29+
30+ /**
31+ * @throws Exception if the test fails
32+ */
33+ @ Test
34+ public void contains () throws Exception {
35+ assertTrue (ArrayUtils .contains (new String [] {"ab" }, "ab" ));
36+ assertTrue (ArrayUtils .contains (new String [] {"o" , "ab" , "cd" }, "ab" ));
37+ assertTrue (ArrayUtils .contains (new String [] {"cd" , "ab" }, "ab" ));
38+
39+ assertFalse (ArrayUtils .contains (null , "ab" ));
40+ assertFalse (ArrayUtils .contains (new String [] {}, "ab" ));
41+ assertFalse (ArrayUtils .contains (new String [] {"cd" , "ab" }, "x" ));
42+
43+ assertThrows (IllegalArgumentException .class , () -> ArrayUtils .contains (new String [] {}, null ));
44+ }
2845
2946 /**
3047 * @throws Exception if the test fails
@@ -35,11 +52,28 @@ public void containsIgnoreCase() throws Exception {
3552 assertTrue (ArrayUtils .containsIgnoreCase (new String [] {"o" , "ab" , "cd" }, "ab" ));
3653 assertTrue (ArrayUtils .containsIgnoreCase (new String [] {"cd" , "ab" }, "ab" ));
3754
55+ assertTrue (ArrayUtils .containsIgnoreCase (new String [] {"ab" }, "aB" ));
56+ assertTrue (ArrayUtils .containsIgnoreCase (new String [] {"o" , "ab" , "cd" }, "Ab" ));
57+ assertTrue (ArrayUtils .containsIgnoreCase (new String [] {"cd" , "ab" }, "AB" ));
58+
3859 assertFalse (ArrayUtils .containsIgnoreCase (null , "ab" ));
3960 assertFalse (ArrayUtils .containsIgnoreCase (new String [] {}, "ab" ));
4061 assertFalse (ArrayUtils .containsIgnoreCase (new String [] {"cd" , "ab" }, "x" ));
4162
42- assertThrows (IllegalArgumentException .class , () -> StringUtils .startsWithIgnoreCase ("AB" , null ));
43- assertThrows (IllegalArgumentException .class , () -> StringUtils .startsWithIgnoreCase (null , null ));
63+ assertThrows (IllegalArgumentException .class , () -> ArrayUtils .containsIgnoreCase (new String [] {}, null ));
64+ }
65+
66+ /**
67+ * @throws Exception if the test fails
68+ */
69+ @ Test
70+ public void containsByte () throws Exception {
71+ assertTrue (ArrayUtils .contains (new byte [] {1 }, (byte ) 1 ));
72+ assertTrue (ArrayUtils .contains (new byte [] {7 , 1 , 9 }, (byte ) 1 ));
73+ assertTrue (ArrayUtils .contains (new byte [] {5 , 2 }, (byte ) 2 ));
74+
75+ assertFalse (ArrayUtils .contains (null , (byte ) 7 ));
76+ assertFalse (ArrayUtils .contains (new byte [] {}, (byte ) 1 ));
77+ assertFalse (ArrayUtils .contains (new byte [] {7 , 9 }, (byte ) 4 ));
4478 }
4579}
0 commit comments