• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package org.apache.commons.lang3;
18 
19 import static org.apache.commons.lang3.ArraySorter.sort;
20 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertFalse;
23 import static org.junit.jupiter.api.Assertions.assertNotNull;
24 import static org.junit.jupiter.api.Assertions.assertNull;
25 import static org.junit.jupiter.api.Assertions.assertSame;
26 import static org.junit.jupiter.api.Assertions.assertThrows;
27 import static org.junit.jupiter.api.Assertions.assertTrue;
28 
29 import java.lang.reflect.Constructor;
30 import java.lang.reflect.Modifier;
31 import java.util.ArrayList;
32 import java.util.Arrays;
33 import java.util.Collections;
34 import java.util.List;
35 
36 import org.junit.jupiter.api.Test;
37 
38 /**
39  * Unit tests {@link BooleanUtils}.
40  */
41 public class BooleanUtilsTest extends AbstractLangTest {
42 
43     @Test
test_booleanValues()44     public void test_booleanValues() {
45         final Boolean[] expected = {Boolean.FALSE, Boolean.TRUE};
46         assertArrayEquals(sort(expected), BooleanUtils.booleanValues());
47     }
48 
49     @Test
test_values()50     public void test_values() {
51         final List<Boolean> expected = Arrays.asList(Boolean.FALSE, Boolean.TRUE);
52         Collections.sort(expected);
53         assertEquals(expected, BooleanUtils.values());
54     }
55 
56     @Test
test_forEach()57     public void test_forEach() {
58         final List<Boolean> list = new ArrayList<>();
59         BooleanUtils.forEach(list::add);
60         assertEquals(Arrays.asList(Boolean.FALSE, Boolean.TRUE), list);
61     }
62 
63     @Test
test_isFalse_Boolean()64     public void test_isFalse_Boolean() {
65         assertFalse(BooleanUtils.isFalse(Boolean.TRUE));
66         assertTrue(BooleanUtils.isFalse(Boolean.FALSE));
67         assertFalse(BooleanUtils.isFalse(null));
68     }
69 
70     @Test
test_isNotFalse_Boolean()71     public void test_isNotFalse_Boolean() {
72         assertTrue(BooleanUtils.isNotFalse(Boolean.TRUE));
73         assertFalse(BooleanUtils.isNotFalse(Boolean.FALSE));
74         assertTrue(BooleanUtils.isNotFalse(null));
75     }
76 
77     @Test
test_isNotTrue_Boolean()78     public void test_isNotTrue_Boolean() {
79         assertFalse(BooleanUtils.isNotTrue(Boolean.TRUE));
80         assertTrue(BooleanUtils.isNotTrue(Boolean.FALSE));
81         assertTrue(BooleanUtils.isNotTrue(null));
82     }
83 
84     @Test
test_isTrue_Boolean()85     public void test_isTrue_Boolean() {
86         assertTrue(BooleanUtils.isTrue(Boolean.TRUE));
87         assertFalse(BooleanUtils.isTrue(Boolean.FALSE));
88         assertFalse(BooleanUtils.isTrue(null));
89     }
90 
91     @Test
test_negate_Boolean()92     public void test_negate_Boolean() {
93         assertSame(null, BooleanUtils.negate(null));
94         assertSame(Boolean.TRUE, BooleanUtils.negate(Boolean.FALSE));
95         assertSame(Boolean.FALSE, BooleanUtils.negate(Boolean.TRUE));
96     }
97 
98     @Test
test_primitiveValues()99     public void test_primitiveValues() {
100         assertArrayEquals(new boolean[] {false, true}, BooleanUtils.primitiveValues());
101     }
102 
103     @Test
test_toBoolean_Boolean()104     public void test_toBoolean_Boolean() {
105         assertTrue(BooleanUtils.toBoolean(Boolean.TRUE));
106         assertFalse(BooleanUtils.toBoolean(Boolean.FALSE));
107         assertFalse(BooleanUtils.toBoolean((Boolean) null));
108     }
109 
110     @Test
test_toBoolean_int()111     public void test_toBoolean_int() {
112         assertTrue(BooleanUtils.toBoolean(1));
113         assertTrue(BooleanUtils.toBoolean(-1));
114         assertFalse(BooleanUtils.toBoolean(0));
115     }
116 
117     @Test
test_toBoolean_int_int_int()118     public void test_toBoolean_int_int_int() {
119         assertTrue(BooleanUtils.toBoolean(6, 6, 7));
120         assertFalse(BooleanUtils.toBoolean(7, 6, 7));
121     }
122 
123     @Test
test_toBoolean_int_int_int_noMatch()124     public void test_toBoolean_int_int_int_noMatch() {
125         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBoolean(8, 6, 7));
126     }
127 
128     @Test
test_toBoolean_Integer_Integer_Integer()129     public void test_toBoolean_Integer_Integer_Integer() {
130         final Integer six = Integer.valueOf(6);
131         final Integer seven = Integer.valueOf(7);
132 
133         assertTrue(BooleanUtils.toBoolean(null, null, seven));
134         assertFalse(BooleanUtils.toBoolean(null, six, null));
135 
136         assertTrue(BooleanUtils.toBoolean(Integer.valueOf(6), six, seven));
137         assertFalse(BooleanUtils.toBoolean(Integer.valueOf(7), six, seven));
138     }
139 
140     @Test
test_toBoolean_Integer_Integer_Integer_noMatch()141     public void test_toBoolean_Integer_Integer_Integer_noMatch() {
142         assertThrows(IllegalArgumentException.class,
143                 () -> BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7)));
144     }
145 
146     @Test
test_toBoolean_Integer_Integer_Integer_nullValue()147     public void test_toBoolean_Integer_Integer_Integer_nullValue() {
148         assertThrows(IllegalArgumentException.class,
149                 () -> BooleanUtils.toBoolean(null, Integer.valueOf(6), Integer.valueOf(7)));
150     }
151 
152     @Test
test_toBoolean_String()153     public void test_toBoolean_String() {
154         assertFalse(BooleanUtils.toBoolean((String) null));
155         assertFalse(BooleanUtils.toBoolean(""));
156         assertFalse(BooleanUtils.toBoolean("off"));
157         assertFalse(BooleanUtils.toBoolean("oof"));
158         assertFalse(BooleanUtils.toBoolean("yep"));
159         assertFalse(BooleanUtils.toBoolean("trux"));
160         assertFalse(BooleanUtils.toBoolean("false"));
161         assertFalse(BooleanUtils.toBoolean("a"));
162         assertTrue(BooleanUtils.toBoolean("true")); // interned handled differently
163         assertTrue(BooleanUtils.toBoolean(new StringBuilder("tr").append("ue").toString()));
164         assertTrue(BooleanUtils.toBoolean("truE"));
165         assertTrue(BooleanUtils.toBoolean("trUe"));
166         assertTrue(BooleanUtils.toBoolean("trUE"));
167         assertTrue(BooleanUtils.toBoolean("tRue"));
168         assertTrue(BooleanUtils.toBoolean("tRuE"));
169         assertTrue(BooleanUtils.toBoolean("tRUe"));
170         assertTrue(BooleanUtils.toBoolean("tRUE"));
171         assertTrue(BooleanUtils.toBoolean("TRUE"));
172         assertTrue(BooleanUtils.toBoolean("TRUe"));
173         assertTrue(BooleanUtils.toBoolean("TRuE"));
174         assertTrue(BooleanUtils.toBoolean("TRue"));
175         assertTrue(BooleanUtils.toBoolean("TrUE"));
176         assertTrue(BooleanUtils.toBoolean("TrUe"));
177         assertTrue(BooleanUtils.toBoolean("TruE"));
178         assertTrue(BooleanUtils.toBoolean("True"));
179         assertTrue(BooleanUtils.toBoolean("on"));
180         assertTrue(BooleanUtils.toBoolean("oN"));
181         assertTrue(BooleanUtils.toBoolean("On"));
182         assertTrue(BooleanUtils.toBoolean("ON"));
183         assertTrue(BooleanUtils.toBoolean("yes"));
184         assertTrue(BooleanUtils.toBoolean("yeS"));
185         assertTrue(BooleanUtils.toBoolean("yEs"));
186         assertTrue(BooleanUtils.toBoolean("yES"));
187         assertTrue(BooleanUtils.toBoolean("Yes"));
188         assertTrue(BooleanUtils.toBoolean("YeS"));
189         assertTrue(BooleanUtils.toBoolean("YEs"));
190         assertTrue(BooleanUtils.toBoolean("YES"));
191         assertTrue(BooleanUtils.toBoolean("1"));
192         assertFalse(BooleanUtils.toBoolean("yes?"));
193         assertFalse(BooleanUtils.toBoolean("0"));
194         assertFalse(BooleanUtils.toBoolean("tru"));
195 
196         assertFalse(BooleanUtils.toBoolean("no"));
197         assertFalse(BooleanUtils.toBoolean("off"));
198         assertFalse(BooleanUtils.toBoolean("yoo"));
199     }
200 
201     @Test
test_toBoolean_String_String_String()202     public void test_toBoolean_String_String_String() {
203         assertTrue(BooleanUtils.toBoolean(null, null, "N"));
204         assertFalse(BooleanUtils.toBoolean(null, "Y", null));
205         assertTrue(BooleanUtils.toBoolean("Y", "Y", "N"));
206         assertTrue(BooleanUtils.toBoolean("Y", "Y", "N"));
207         assertFalse(BooleanUtils.toBoolean("N", "Y", "N"));
208         assertFalse(BooleanUtils.toBoolean("N", "Y", "N"));
209         assertTrue(BooleanUtils.toBoolean((String) null, null, null));
210         assertTrue(BooleanUtils.toBoolean("Y", "Y", "Y"));
211         assertTrue(BooleanUtils.toBoolean("Y", "Y", "Y"));
212     }
213 
214     @Test
test_toBoolean_String_String_String_noMatch()215     public void test_toBoolean_String_String_String_noMatch() {
216         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBoolean("X", "Y", "N"));
217     }
218 
219     @Test
test_toBoolean_String_String_String_nullValue()220     public void test_toBoolean_String_String_String_nullValue() {
221         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBoolean(null, "Y", "N"));
222     }
223 
224     @Test
test_toBooleanDefaultIfNull_Boolean_boolean()225     public void test_toBooleanDefaultIfNull_Boolean_boolean() {
226         assertTrue(BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, true));
227         assertTrue(BooleanUtils.toBooleanDefaultIfNull(Boolean.TRUE, false));
228         assertFalse(BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, true));
229         assertFalse(BooleanUtils.toBooleanDefaultIfNull(Boolean.FALSE, false));
230         assertTrue(BooleanUtils.toBooleanDefaultIfNull(null, true));
231         assertFalse(BooleanUtils.toBooleanDefaultIfNull(null, false));
232     }
233 
234     @Test
test_toBooleanObject_int()235     public void test_toBooleanObject_int() {
236         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1));
237         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1));
238         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0));
239     }
240 
241     @Test
test_toBooleanObject_int_int_int()242     public void test_toBooleanObject_int_int_int() {
243         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8));
244         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8));
245         assertNull(BooleanUtils.toBooleanObject(8, 6, 7, 8));
246     }
247 
248     @Test
test_toBooleanObject_int_int_int_noMatch()249     public void test_toBooleanObject_int_int_int_noMatch() {
250         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBooleanObject(9, 6, 7, 8));
251     }
252 
253     @Test
test_toBooleanObject_Integer()254     public void test_toBooleanObject_Integer() {
255         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1)));
256         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1)));
257         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0)));
258         assertNull(BooleanUtils.toBooleanObject((Integer) null));
259     }
260 
261     @Test
test_toBooleanObject_Integer_Integer_Integer_Integer()262     public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
263         final Integer six = Integer.valueOf(6);
264         final Integer seven = Integer.valueOf(7);
265         final Integer eight = Integer.valueOf(8);
266 
267         assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, seven, eight));
268         assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(null, six, null, eight));
269         assertSame(null, BooleanUtils.toBooleanObject(null, six, seven, null));
270 
271         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight));
272         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight));
273         assertNull(BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight));
274     }
275 
276     @Test
test_toBooleanObject_Integer_Integer_Integer_Integer_noMatch()277     public void test_toBooleanObject_Integer_Integer_Integer_Integer_noMatch() {
278         assertThrows(IllegalArgumentException.class,
279                 () -> BooleanUtils.toBooleanObject(Integer.valueOf(9), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8)));
280     }
281 
282     @Test
test_toBooleanObject_Integer_Integer_Integer_Integer_nullValue()283     public void test_toBooleanObject_Integer_Integer_Integer_Integer_nullValue() {
284         assertThrows(IllegalArgumentException.class,
285                 () -> BooleanUtils.toBooleanObject(null, Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8)));
286     }
287 
288     @Test
test_toBooleanObject_String()289     public void test_toBooleanObject_String() {
290         assertNull(BooleanUtils.toBooleanObject((String) null));
291         assertNull(BooleanUtils.toBooleanObject(""));
292         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("false"));
293         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("no"));
294         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("off"));
295         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("FALSE"));
296         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("NO"));
297         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("OFF"));
298         assertNull(BooleanUtils.toBooleanObject("oof"));
299         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("true"));
300         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("yes"));
301         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("on"));
302         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TRUE"));
303         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("ON"));
304         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("YES"));
305         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
306         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
307 
308         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("y")); // yes
309         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y"));
310         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("t")); // true
311         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("T"));
312         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("1"));
313         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("f")); // false
314         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("F"));
315         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("n")); // No
316         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N"));
317         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("0"));
318         assertNull(BooleanUtils.toBooleanObject("z"));
319 
320         assertNull(BooleanUtils.toBooleanObject("ab"));
321         assertNull(BooleanUtils.toBooleanObject("yoo"));
322         assertNull(BooleanUtils.toBooleanObject("true "));
323         assertNull(BooleanUtils.toBooleanObject("ono"));
324     }
325 
326     @Test
test_toBooleanObject_String_String_String_String()327     public void test_toBooleanObject_String_String_String_String() {
328         assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, "N", "U"));
329         assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(null, "Y", null, "U"));
330         assertSame(null, BooleanUtils.toBooleanObject(null, "Y", "N", null));
331 
332         assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
333         assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
334         assertNull(BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
335     }
336 
337     @Test
test_toBooleanObject_String_String_String_String_noMatch()338     public void test_toBooleanObject_String_String_String_String_noMatch() {
339         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBooleanObject("X", "Y", "N", "U"));
340     }
341 
342     @Test
test_toBooleanObject_String_String_String_String_nullValue()343     public void test_toBooleanObject_String_String_String_String_nullValue() {
344         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.toBooleanObject(null, "Y", "N", "U"));
345     }
346 
347     @Test
test_toInteger_boolean()348     public void test_toInteger_boolean() {
349         assertEquals(1, BooleanUtils.toInteger(true));
350         assertEquals(0, BooleanUtils.toInteger(false));
351     }
352 
353     @Test
test_toInteger_boolean_int_int()354     public void test_toInteger_boolean_int_int() {
355         assertEquals(6, BooleanUtils.toInteger(true, 6, 7));
356         assertEquals(7, BooleanUtils.toInteger(false, 6, 7));
357     }
358 
359     @Test
test_toInteger_Boolean_int_int_int()360     public void test_toInteger_Boolean_int_int_int() {
361         assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8));
362         assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8));
363         assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8));
364     }
365 
366     @Test
test_toIntegerObject_boolean()367     public void test_toIntegerObject_boolean() {
368         assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(true));
369         assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(false));
370     }
371 
372     @Test
test_toIntegerObject_Boolean()373     public void test_toIntegerObject_Boolean() {
374         assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(Boolean.TRUE));
375         assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(Boolean.FALSE));
376         assertNull(BooleanUtils.toIntegerObject(null));
377     }
378 
379     @Test
test_toIntegerObject_boolean_Integer_Integer()380     public void test_toIntegerObject_boolean_Integer_Integer() {
381         final Integer six = Integer.valueOf(6);
382         final Integer seven = Integer.valueOf(7);
383         assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven));
384         assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven));
385     }
386 
387     @Test
test_toIntegerObject_Boolean_Integer_Integer_Integer()388     public void test_toIntegerObject_Boolean_Integer_Integer_Integer() {
389         final Integer six = Integer.valueOf(6);
390         final Integer seven = Integer.valueOf(7);
391         final Integer eight = Integer.valueOf(8);
392         assertEquals(six, BooleanUtils.toIntegerObject(Boolean.TRUE, six, seven, eight));
393         assertEquals(seven, BooleanUtils.toIntegerObject(Boolean.FALSE, six, seven, eight));
394         assertEquals(eight, BooleanUtils.toIntegerObject(null, six, seven, eight));
395         assertNull(BooleanUtils.toIntegerObject(null, six, seven, null));
396     }
397 
398     @Test
test_toString_boolean_String_String_String()399     public void test_toString_boolean_String_String_String() {
400         assertEquals("Y", BooleanUtils.toString(true, "Y", "N"));
401         assertEquals("N", BooleanUtils.toString(false, "Y", "N"));
402     }
403 
404     @Test
test_toString_Boolean_String_String_String()405     public void test_toString_Boolean_String_String_String() {
406         assertEquals("U", BooleanUtils.toString(null, "Y", "N", "U"));
407         assertEquals("Y", BooleanUtils.toString(Boolean.TRUE, "Y", "N", "U"));
408         assertEquals("N", BooleanUtils.toString(Boolean.FALSE, "Y", "N", "U"));
409     }
410 
411     @Test
test_toStringOnOff_boolean()412     public void test_toStringOnOff_boolean() {
413         assertEquals("on", BooleanUtils.toStringOnOff(true));
414         assertEquals("off", BooleanUtils.toStringOnOff(false));
415     }
416 
417     @Test
test_toStringOnOff_Boolean()418     public void test_toStringOnOff_Boolean() {
419         assertNull(BooleanUtils.toStringOnOff(null));
420         assertEquals("on", BooleanUtils.toStringOnOff(Boolean.TRUE));
421         assertEquals("off", BooleanUtils.toStringOnOff(Boolean.FALSE));
422     }
423 
424     @Test
test_toStringTrueFalse_boolean()425     public void test_toStringTrueFalse_boolean() {
426         assertEquals("true", BooleanUtils.toStringTrueFalse(true));
427         assertEquals("false", BooleanUtils.toStringTrueFalse(false));
428     }
429 
430     @Test
test_toStringTrueFalse_Boolean()431     public void test_toStringTrueFalse_Boolean() {
432         assertNull(BooleanUtils.toStringTrueFalse(null));
433         assertEquals("true", BooleanUtils.toStringTrueFalse(Boolean.TRUE));
434         assertEquals("false", BooleanUtils.toStringTrueFalse(Boolean.FALSE));
435     }
436 
437     @Test
test_toStringYesNo_boolean()438     public void test_toStringYesNo_boolean() {
439         assertEquals("yes", BooleanUtils.toStringYesNo(true));
440         assertEquals("no", BooleanUtils.toStringYesNo(false));
441     }
442 
443     @Test
test_toStringYesNo_Boolean()444     public void test_toStringYesNo_Boolean() {
445         assertNull(BooleanUtils.toStringYesNo(null));
446         assertEquals("yes", BooleanUtils.toStringYesNo(Boolean.TRUE));
447         assertEquals("no", BooleanUtils.toStringYesNo(Boolean.FALSE));
448     }
449 
450     @Test
testAnd_object_emptyInput()451     public void testAnd_object_emptyInput() {
452         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.and(new Boolean[] {}));
453     }
454 
455     @Test
testAnd_object_nullElementInput()456     public void testAnd_object_nullElementInput() {
457         assertEquals(Boolean.FALSE, BooleanUtils.and(new Boolean[] {null}));
458     }
459 
460     @Test
testAnd_object_nullInput()461     public void testAnd_object_nullInput() {
462         assertThrows(NullPointerException.class, () -> BooleanUtils.and((Boolean[]) null));
463     }
464 
465     @Test
testAnd_object_validInput_2items()466     public void testAnd_object_validInput_2items() {
467         assertTrue(
468                 BooleanUtils
469                     .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE })
470                     .booleanValue(),
471                 "False result for (true, true)");
472 
473         assertFalse(
474                 BooleanUtils
475                     .and(new Boolean[] { Boolean.FALSE, Boolean.FALSE })
476                     .booleanValue(),
477                 "True result for (false, false)");
478 
479         assertFalse(
480                 BooleanUtils
481                     .and(new Boolean[] { Boolean.TRUE, Boolean.FALSE })
482                     .booleanValue(),
483                 "True result for (true, false)");
484 
485         assertFalse(
486                 BooleanUtils
487                     .and(new Boolean[] { Boolean.FALSE, Boolean.TRUE })
488                     .booleanValue(),
489                 "True result for (false, true)");
490     }
491 
492     @Test
testAnd_object_validInput_3items()493     public void testAnd_object_validInput_3items() {
494         assertFalse(
495                 BooleanUtils
496                     .and(
497                         new Boolean[] {
498                             Boolean.FALSE,
499                             Boolean.FALSE,
500                             Boolean.TRUE })
501                             .booleanValue(),
502                 "True result for (false, false, true)");
503 
504         assertFalse(
505                 BooleanUtils
506                     .and(
507                         new Boolean[] {
508                             Boolean.FALSE,
509                             Boolean.TRUE,
510                             Boolean.FALSE })
511                             .booleanValue(),
512                 "True result for (false, true, false)");
513 
514         assertFalse(
515                 BooleanUtils
516                     .and(
517                         new Boolean[] {
518                             Boolean.TRUE,
519                             Boolean.FALSE,
520                             Boolean.FALSE })
521                             .booleanValue(),
522                 "True result for (true, false, false)");
523 
524         assertTrue(
525                 BooleanUtils
526                     .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE })
527                     .booleanValue(),
528                 "False result for (true, true, true)");
529 
530         assertFalse(
531                 BooleanUtils.and(
532                         new Boolean[] {
533                             Boolean.FALSE,
534                             Boolean.FALSE,
535                             Boolean.FALSE })
536                             .booleanValue(),
537                 "True result for (false, false)");
538 
539         assertFalse(
540                 BooleanUtils.and(
541                         new Boolean[] {
542                             Boolean.TRUE,
543                             Boolean.TRUE,
544                             Boolean.FALSE })
545                             .booleanValue(),
546                 "True result for (true, true, false)");
547 
548         assertFalse(
549                 BooleanUtils.and(
550                         new Boolean[] {
551                             Boolean.TRUE,
552                             Boolean.FALSE,
553                             Boolean.TRUE })
554                             .booleanValue(),
555                 "True result for (true, false, true)");
556 
557         assertFalse(
558                 BooleanUtils.and(
559                         new Boolean[] {
560                             Boolean.FALSE,
561                             Boolean.TRUE,
562                             Boolean.TRUE })
563                             .booleanValue(),
564                 "True result for (false, true, true)");
565     }
566 
567     @Test
testAnd_primitive_emptyInput()568     public void testAnd_primitive_emptyInput() {
569         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.and(new boolean[] {}));
570     }
571 
572     @Test
testAnd_primitive_nullInput()573     public void testAnd_primitive_nullInput() {
574         assertThrows(NullPointerException.class, () -> BooleanUtils.and((boolean[]) null));
575     }
576 
577     @Test
testAnd_primitive_validInput_2items()578     public void testAnd_primitive_validInput_2items() {
579         assertTrue(
580                 BooleanUtils.and(new boolean[] { true, true }),
581                 "False result for (true, true)");
582 
583         assertFalse(
584                 BooleanUtils.and(new boolean[] { false, false }),
585                 "True result for (false, false)");
586 
587         assertFalse(
588                 BooleanUtils.and(new boolean[] { true, false }),
589                 "True result for (true, false)");
590 
591         assertFalse(
592                 BooleanUtils.and(new boolean[] { false, true }),
593                 "True result for (false, true)");
594     }
595 
596     @Test
testAnd_primitive_validInput_3items()597     public void testAnd_primitive_validInput_3items() {
598         assertFalse(
599                 BooleanUtils.and(new boolean[] { false, false, true }),
600                 "True result for (false, false, true)");
601 
602         assertFalse(
603                 BooleanUtils.and(new boolean[] { false, true, false }),
604                 "True result for (false, true, false)");
605 
606         assertFalse(
607                 BooleanUtils.and(new boolean[] { true, false, false }),
608                 "True result for (true, false, false)");
609 
610         assertTrue(
611                 BooleanUtils.and(new boolean[] { true, true, true }),
612                 "False result for (true, true, true)");
613 
614         assertFalse(
615                 BooleanUtils.and(new boolean[] { false, false, false }),
616                 "True result for (false, false)");
617 
618         assertFalse(
619                 BooleanUtils.and(new boolean[] { true, true, false }),
620                 "True result for (true, true, false)");
621 
622         assertFalse(
623                 BooleanUtils.and(new boolean[] { true, false, true }),
624                 "True result for (true, false, true)");
625 
626         assertFalse(
627                 BooleanUtils.and(new boolean[] { false, true, true }),
628                 "True result for (false, true, true)");
629     }
630 
631     @Test
testCompare()632     public void testCompare() {
633         assertTrue(BooleanUtils.compare(true, false) > 0);
634         assertEquals(0, BooleanUtils.compare(true, true));
635         assertEquals(0, BooleanUtils.compare(false, false));
636         assertTrue(BooleanUtils.compare(false, true) < 0);
637     }
638 
639     @Test
640     public void testConstructor() {
641         assertNotNull(new BooleanUtils());
642         final Constructor<?>[] cons = BooleanUtils.class.getDeclaredConstructors();
643         assertEquals(1, cons.length);
644         assertTrue(Modifier.isPublic(cons[0].getModifiers()));
645         assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers()));
646         assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers()));
647     }
648 
649     @Test
650     public void testOneHot_object_emptyInput() {
651         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.oneHot(new Boolean[] {}));
652     }
653 
654     @Test
testOneHot_object_nullElementInput()655     public void testOneHot_object_nullElementInput() {
656         assertEquals(Boolean.FALSE, BooleanUtils.oneHot(new Boolean[] {null}));
657     }
658 
659     @Test
testOneHot_object_nullInput()660     public void testOneHot_object_nullInput() {
661         assertThrows(NullPointerException.class, () -> BooleanUtils.oneHot((Boolean[]) null));
662     }
663 
664     @Test
testOneHot_object_validInput_1item()665     public void testOneHot_object_validInput_1item() {
666         assertTrue(BooleanUtils.oneHot(new Boolean[]{Boolean.TRUE}), "true");
667 
668         assertFalse(BooleanUtils.oneHot(new Boolean[]{Boolean.FALSE}), "false");
669 
670         assertFalse(BooleanUtils.oneHot(new Boolean[]{null}), "false");
671     }
672 
673     @Test
testOneHot_object_validInput_2items()674     public void testOneHot_object_validInput_2items() {
675         assertFalse(BooleanUtils.oneHot(new Boolean[]{true, true}), "both true");
676 
677         assertFalse(BooleanUtils.oneHot(new Boolean[]{false, false}), "both false");
678 
679         assertTrue(BooleanUtils.oneHot(new Boolean[]{true, false}), "first true");
680 
681         assertTrue(BooleanUtils.oneHot(new Boolean[]{false, true}), "last true");
682     }
683 
684     @Test
testOneHot_object_validInput_2ItemsNullsTreatedAsFalse()685     public void testOneHot_object_validInput_2ItemsNullsTreatedAsFalse() {
686         assertFalse(BooleanUtils.oneHot(null, null), "both null");
687 
688         assertTrue(BooleanUtils.oneHot(true, null), "first true");
689 
690         assertTrue(BooleanUtils.oneHot(null, true), "last true");
691     }
692 
693     @Test
testOneHot_object_validInput_3items()694     public void testOneHot_object_validInput_3items() {
695         // none true
696         assertFalse(BooleanUtils.oneHot(new Boolean[]{false, false, false}), "all false");
697 
698         // one true
699         assertTrue(BooleanUtils.oneHot(new Boolean[]{true, false, false}), "first true");
700 
701         assertTrue(BooleanUtils.oneHot(new Boolean[]{false, true, false}), "middle true");
702 
703         assertTrue(BooleanUtils.oneHot(new Boolean[]{false, false, true}), "last true");
704 
705         // two true
706         assertFalse(BooleanUtils.oneHot(new Boolean[]{false, true, true}), "first false");
707 
708         assertFalse(BooleanUtils.oneHot(new Boolean[]{true, false, true}), "middle false");
709 
710         assertFalse(BooleanUtils.oneHot(new Boolean[]{true, true, false}), "last false");
711 
712         // three true
713         assertFalse(BooleanUtils.oneHot(new Boolean[]{true, true, true}), "all true");
714     }
715 
716     @Test
testOneHot_primitive_emptyInput()717     public void testOneHot_primitive_emptyInput() {
718         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.oneHot(new boolean[] {}));
719     }
720 
721     @Test
testOneHot_primitive_nullInput()722     public void testOneHot_primitive_nullInput() {
723         assertThrows(NullPointerException.class, () -> BooleanUtils.oneHot((boolean[]) null));
724     }
725 
726     @Test
testOneHot_primitive_validInput_1item()727     public void testOneHot_primitive_validInput_1item() {
728         assertTrue(BooleanUtils.oneHot(new boolean[]{true}), "true");
729 
730         assertFalse(BooleanUtils.oneHot(new boolean[]{false}), "false");
731     }
732 
733     @Test
testOneHot_primitive_validInput_2items()734     public void testOneHot_primitive_validInput_2items() {
735         assertFalse(BooleanUtils.oneHot(new boolean[]{true, true}), "both true");
736 
737         assertFalse(BooleanUtils.oneHot(new boolean[]{false, false}), "both false");
738 
739         assertTrue(BooleanUtils.oneHot(new boolean[]{true, false}), "first true");
740 
741         assertTrue(BooleanUtils.oneHot(new boolean[]{false, true}), "last true");
742     }
743 
744     @Test
testOneHot_primitive_validInput_3items()745     public void testOneHot_primitive_validInput_3items() {
746         // none true
747         assertFalse(BooleanUtils.oneHot(new boolean[]{false, false, false}), "all false");
748 
749         // one true
750         assertTrue(BooleanUtils.oneHot(new boolean[]{true, false, false}), "first true");
751 
752         assertTrue(BooleanUtils.oneHot(new boolean[]{false, true, false}), "middle true");
753 
754         assertTrue(BooleanUtils.oneHot(new boolean[]{false, false, true}), "last true");
755 
756         // two true
757         assertFalse(BooleanUtils.oneHot(new boolean[]{false, true, true}), "first false");
758 
759         assertFalse(BooleanUtils.oneHot(new boolean[]{true, false, true}), "middle false");
760 
761         assertFalse(BooleanUtils.oneHot(new boolean[]{true, true, false}), "last false");
762 
763         // three true
764         assertFalse(BooleanUtils.oneHot(new boolean[]{true, true, true}), "all true");
765     }
766 
767     @Test
testOr_object_emptyInput()768     public void testOr_object_emptyInput() {
769         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.or(new Boolean[] {}));
770     }
771 
772     @Test
testOr_object_nullElementInput()773     public void testOr_object_nullElementInput() {
774         assertEquals(Boolean.FALSE, BooleanUtils.or(new Boolean[] {null}));
775     }
776 
777     @Test
testOr_object_nullInput()778     public void testOr_object_nullInput() {
779         assertThrows(NullPointerException.class, () -> BooleanUtils.or((Boolean[]) null));
780     }
781 
782     @Test
testOr_object_validInput_2items()783     public void testOr_object_validInput_2items() {
784         assertTrue(
785                 BooleanUtils
786                     .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE })
787                     .booleanValue(),
788                 "False result for (true, true)");
789 
790         assertFalse(
791                 BooleanUtils
792                     .or(new Boolean[] { Boolean.FALSE, Boolean.FALSE })
793                     .booleanValue(),
794                 "True result for (false, false)");
795 
796         assertTrue(
797                 BooleanUtils
798                     .or(new Boolean[] { Boolean.TRUE, Boolean.FALSE })
799                     .booleanValue(),
800                 "False result for (true, false)");
801 
802         assertTrue(
803                 BooleanUtils
804                     .or(new Boolean[] { Boolean.FALSE, Boolean.TRUE })
805                     .booleanValue(),
806                 "False result for (false, true)");
807     }
808 
809     @Test
testOr_object_validInput_3items()810     public void testOr_object_validInput_3items() {
811         assertTrue(
812                 BooleanUtils
813                     .or(
814                         new Boolean[] {
815                             Boolean.FALSE,
816                             Boolean.FALSE,
817                             Boolean.TRUE })
818                             .booleanValue(),
819                 "False result for (false, false, true)");
820 
821         assertTrue(
822                 BooleanUtils
823                     .or(
824                         new Boolean[] {
825                             Boolean.FALSE,
826                             Boolean.TRUE,
827                             Boolean.FALSE })
828                             .booleanValue(),
829                 "False result for (false, true, false)");
830 
831         assertTrue(
832                 BooleanUtils
833                     .or(
834                         new Boolean[] {
835                             Boolean.TRUE,
836                             Boolean.FALSE,
837                             Boolean.FALSE })
838                             .booleanValue(),
839                 "False result for (true, false, false)");
840 
841         assertTrue(
842                 BooleanUtils
843                     .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE })
844                     .booleanValue(),
845                 "False result for (true, true, true)");
846 
847         assertFalse(
848                 BooleanUtils.or(
849                         new Boolean[] {
850                             Boolean.FALSE,
851                             Boolean.FALSE,
852                             Boolean.FALSE })
853                             .booleanValue(),
854                 "True result for (false, false)");
855 
856         assertTrue(
857                 BooleanUtils.or(
858                         new Boolean[] {
859                             Boolean.TRUE,
860                             Boolean.TRUE,
861                             Boolean.FALSE })
862                             .booleanValue(),
863                 "False result for (true, true, false)");
864 
865         assertTrue(
866                 BooleanUtils.or(
867                         new Boolean[] {
868                             Boolean.TRUE,
869                             Boolean.FALSE,
870                             Boolean.TRUE })
871                             .booleanValue(),
872                 "False result for (true, false, true)");
873 
874         assertTrue(
875                 BooleanUtils.or(
876                         new Boolean[] {
877                             Boolean.FALSE,
878                             Boolean.TRUE,
879                             Boolean.TRUE })
880                             .booleanValue(),
881                 "False result for (false, true, true)");
882     }
883 
884     @Test
testOr_primitive_emptyInput()885     public void testOr_primitive_emptyInput() {
886         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.or(new boolean[] {}));
887     }
888 
889     @Test
testOr_primitive_nullInput()890     public void testOr_primitive_nullInput() {
891         assertThrows(NullPointerException.class, () -> BooleanUtils.or((boolean[]) null));
892     }
893 
894     @Test
testOr_primitive_validInput_2items()895     public void testOr_primitive_validInput_2items() {
896         assertTrue(
897                 BooleanUtils.or(new boolean[] { true, true }),
898                 "False result for (true, true)");
899 
900         assertFalse(
901                 BooleanUtils.or(new boolean[] { false, false }),
902                 "True result for (false, false)");
903 
904         assertTrue(
905                 BooleanUtils.or(new boolean[] { true, false }),
906                 "False result for (true, false)");
907 
908         assertTrue(
909                 BooleanUtils.or(new boolean[] { false, true }),
910                 "False result for (false, true)");
911     }
912 
913     @Test
testOr_primitive_validInput_3items()914     public void testOr_primitive_validInput_3items() {
915         assertTrue(
916                 BooleanUtils.or(new boolean[] { false, false, true }),
917                 "False result for (false, false, true)");
918 
919         assertTrue(
920                 BooleanUtils.or(new boolean[] { false, true, false }),
921                 "False result for (false, true, false)");
922 
923         assertTrue(
924                 BooleanUtils.or(new boolean[] { true, false, false }),
925                 "False result for (true, false, false)");
926 
927         assertTrue(
928                 BooleanUtils.or(new boolean[] { true, true, true }),
929                 "False result for (true, true, true)");
930 
931         assertFalse(
932                 BooleanUtils.or(new boolean[] { false, false, false }),
933                 "True result for (false, false)");
934 
935         assertTrue(
936                 BooleanUtils.or(new boolean[] { true, true, false }),
937                 "False result for (true, true, false)");
938 
939         assertTrue(
940                 BooleanUtils.or(new boolean[] { true, false, true }),
941                 "False result for (true, false, true)");
942 
943         assertTrue(
944                 BooleanUtils.or(new boolean[] { false, true, true }),
945                 "False result for (false, true, true)");
946     }
947 
948     @Test
testXor_object_emptyInput()949     public void testXor_object_emptyInput() {
950         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.xor(new Boolean[] {}));
951     }
952 
953     @Test
testXor_object_nullElementInput()954     public void testXor_object_nullElementInput() {
955         assertEquals(Boolean.FALSE, BooleanUtils.xor(new Boolean[] {null}));
956     }
957 
958     @Test
testXor_object_nullInput()959     public void testXor_object_nullInput() {
960         assertThrows(NullPointerException.class, () -> BooleanUtils.xor((Boolean[]) null));
961     }
962 
963     @Test
testXor_object_validInput_1items()964     public void testXor_object_validInput_1items() {
965         assertEquals(
966                 true,
967                 BooleanUtils.xor(new Boolean[] { Boolean.TRUE }).booleanValue(),
968                 "true");
969 
970         assertEquals(
971                 false,
972                 BooleanUtils.xor(new Boolean[] { Boolean.FALSE }).booleanValue(),
973                 "false");
974     }
975 
976     @Test
testXor_object_validInput_2items()977     public void testXor_object_validInput_2items() {
978         assertEquals(
979                 false ^ false,
980                 BooleanUtils.xor(new Boolean[] { Boolean.FALSE, Boolean.FALSE }).booleanValue(),
981                 "false ^ false");
982 
983         assertEquals(
984                 false ^ true,
985                 BooleanUtils.xor(new Boolean[] { Boolean.FALSE, Boolean.TRUE }).booleanValue(),
986                 "false ^ true");
987 
988         assertEquals(
989                 true ^ false,
990                 BooleanUtils.xor(new Boolean[] { Boolean.TRUE, Boolean.FALSE }).booleanValue(),
991                 "true ^ false");
992 
993         assertEquals(
994                 true ^ true,
995                 BooleanUtils.xor(new Boolean[] { Boolean.TRUE, Boolean.TRUE }).booleanValue(),
996                 "true ^ true");
997     }
998 
999     @Test
testXor_object_validInput_3items()1000     public void testXor_object_validInput_3items() {
1001         assertEquals(
1002                 false ^ false ^ false,
1003                 BooleanUtils.xor(
1004                                 new Boolean[] {
1005                                         Boolean.FALSE,
1006                                         Boolean.FALSE,
1007                                         Boolean.FALSE })
1008                                 .booleanValue(),
1009                 "false ^ false ^ false");
1010 
1011         assertEquals(
1012                 false ^ false ^ true,
1013                 BooleanUtils
1014                         .xor(
1015                             new Boolean[] {
1016                                 Boolean.FALSE,
1017                                 Boolean.FALSE,
1018                                 Boolean.TRUE })
1019                         .booleanValue(),
1020                 "false ^ false ^ true");
1021 
1022         assertEquals(
1023                 false ^ true ^ false,
1024                 BooleanUtils
1025                         .xor(
1026                             new Boolean[] {
1027                                 Boolean.FALSE,
1028                                 Boolean.TRUE,
1029                                 Boolean.FALSE })
1030                         .booleanValue(),
1031                 "false ^ true ^ false");
1032 
1033         assertEquals(
1034                 true ^ false ^ false,
1035                 BooleanUtils
1036                         .xor(
1037                             new Boolean[] {
1038                                 Boolean.TRUE,
1039                                 Boolean.FALSE,
1040                                 Boolean.FALSE })
1041                         .booleanValue(),
1042                 "true ^ false ^ false");
1043 
1044         assertEquals(
1045                 true ^ false ^ true,
1046                 BooleanUtils.xor(
1047                                 new Boolean[] {
1048                                         Boolean.TRUE,
1049                                         Boolean.FALSE,
1050                                         Boolean.TRUE })
1051                                 .booleanValue(),
1052                 "true ^ false ^ true");
1053 
1054         assertEquals(
1055                 true ^ true ^ false,
1056                 BooleanUtils.xor(
1057                             new Boolean[] {
1058                                 Boolean.TRUE,
1059                                 Boolean.TRUE,
1060                                 Boolean.FALSE })
1061                         .booleanValue(),
1062                 "true ^ true ^ false");
1063 
1064         assertEquals(
1065                 false ^ true ^ true,
1066                 BooleanUtils.xor(
1067                             new Boolean[] {
1068                                 Boolean.FALSE,
1069                                 Boolean.TRUE,
1070                                 Boolean.TRUE })
1071                         .booleanValue(),
1072                 "false ^ true ^ true");
1073 
1074         assertEquals(
1075                 true ^ true ^ true,
1076                 BooleanUtils.xor(
1077                         new Boolean[] {
1078                                 Boolean.TRUE,
1079                                 Boolean.TRUE,
1080                                 Boolean.TRUE })
1081                         .booleanValue(),
1082                 "true ^ true ^ true");
1083     }
1084 
1085     @Test
testXor_primitive_emptyInput()1086     public void testXor_primitive_emptyInput() {
1087         assertThrows(IllegalArgumentException.class, () -> BooleanUtils.xor(new boolean[] {}));
1088     }
1089 
1090     @Test
testXor_primitive_nullInput()1091     public void testXor_primitive_nullInput() {
1092         assertThrows(NullPointerException.class, () -> BooleanUtils.xor((boolean[]) null));
1093     }
1094 
1095     @Test
testXor_primitive_validInput_1items()1096     public void testXor_primitive_validInput_1items() {
1097         assertEquals(
1098                 true,
1099                 BooleanUtils.xor(new boolean[] { true }),
1100                 "true");
1101 
1102         assertEquals(
1103                 false,
1104                 BooleanUtils.xor(new boolean[] { false }),
1105                 "false");
1106     }
1107 
1108     @Test
testXor_primitive_validInput_2items()1109     public void testXor_primitive_validInput_2items() {
1110         assertEquals(
1111                 true ^ true,
1112                 BooleanUtils.xor(new boolean[] { true, true }),
1113                 "true ^ true");
1114 
1115         assertEquals(
1116                 false ^ false,
1117                 BooleanUtils.xor(new boolean[] { false, false }),
1118                 "false ^ false");
1119 
1120         assertEquals(
1121                 true ^ false,
1122                 BooleanUtils.xor(new boolean[] { true, false }),
1123                 "true ^ false");
1124 
1125         assertEquals(
1126                 false ^ true,
1127                 BooleanUtils.xor(new boolean[] { false, true }),
1128                 "false ^ true");
1129     }
1130 
1131     @Test
testXor_primitive_validInput_3items()1132     public void testXor_primitive_validInput_3items() {
1133         assertEquals(
1134                 false ^ false ^ false,
1135                 BooleanUtils.xor(new boolean[] { false, false, false }),
1136                 "false ^ false ^ false");
1137 
1138         assertEquals(
1139                 false ^ false ^ true,
1140                 BooleanUtils.xor(new boolean[] { false, false, true }),
1141                 "false ^ false ^ true");
1142 
1143         assertEquals(
1144                 false ^ true ^ false,
1145                 BooleanUtils.xor(new boolean[] { false, true, false }),
1146                 "false ^ true ^ false");
1147 
1148         assertEquals(
1149                 false ^ true ^ true,
1150                 BooleanUtils.xor(new boolean[] { false, true, true }),
1151                 "false ^ true ^ true");
1152 
1153         assertEquals(
1154                 true ^ false ^ false,
1155                 BooleanUtils.xor(new boolean[] { true, false, false }),
1156                 "true ^ false ^ false");
1157 
1158         assertEquals(
1159                 true ^ false ^ true,
1160                 BooleanUtils.xor(new boolean[] { true, false, true }),
1161                 "true ^ false ^ true");
1162 
1163         assertEquals(
1164                 true ^ true ^ false,
1165                 BooleanUtils.xor(new boolean[] { true, true, false }),
1166                 "true ^ true ^ false");
1167 
1168         assertEquals(
1169                 true ^ true ^ true,
1170                 BooleanUtils.xor(new boolean[] { true, true, true }),
1171                 "true ^ true ^ true");
1172     }
1173 }
1174