Adjust unit test for intentional behaviour change of Util.objsAreEqual().
[cfb.git] / test / net / jaekl / cfb / util / UtilTest.java
1 package net.jaekl.cfb.util;
2
3 import static org.junit.Assert.*;
4
5 import java.util.Arrays;
6 import java.util.List;
7
8 import org.junit.Test;
9
10 public class UtilTest {
11         @Test
12         public void testListsAreEqual()
13         {
14                 Object[][][] equal = {
15                                 {
16                                         null,
17                                         null
18                                 },
19                                 {
20                                         { "one", "two", "three" },
21                                         { "one", "two", "three" }
22                                 },
23                                 {
24                                         { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
25                                         { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) }
26                                 },
27                                 {
28                                         { Integer.valueOf(1), Integer.valueOf(2048), Integer.valueOf(3) },
29                                         { Integer.valueOf(1), Integer.valueOf(2048), Long.valueOf(3) }
30                                 }                               
31                 };
32                 Object[][][] unequal = {
33                                 {
34                                         null,
35                                         { "one", "two", "three" }
36                                 },
37                                 {
38                                         { "1", "1", "2" },
39                                         { "1", "2", "1" }
40                                 },
41                                 {
42                                         { "1", "1", "2" },
43                                         { "1", "2", "2" }
44                                 },
45                                 {
46                                         { "1", "1", "2" },
47                                         { "1", "2" }
48                                 },
49                                 {
50                                         { "1", "2", "3" },
51                                         { Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3) }
52                                 }
53                 };
54
55                 for (Object[][] lists : equal) {
56                         List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
57                         List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
58                         boolean result = Util.listsAreEqual(a, b);
59                         assertTrue(result);
60                 }
61                 
62                 for (Object[][] lists : unequal) {
63                         List<?> a = (null == lists[0]) ? null : Arrays.asList(lists[0]);
64                         List<?> b = (null == lists[1]) ? null : Arrays.asList(lists[1]);
65                         boolean result = Util.listsAreEqual(a, b);
66                         assertFalse(result);
67                 }
68         }
69 }