BooleanArrayDifference extends AbstractDifferenceList implements IDifferenceList { public static IDifference construct(String name, boolean[] first, boolean[] second) { if (first == null && second == null) return null; BooleanArrayDifference totalDiff = new BooleanArrayDifference(name); int firstLength = first == null ? 0 : first.length; int secondLength = second == null ? 0 : second.length; if (firstLength == secondLength) { for (int i = 0; i < firstLength; i++) { totalDiff.addChild(BooleanDifference.construct("" + i, first[i], second[i])); } } else if (firstLength < secondLength) { for (int i = 0; i < firstLength; i++) { totalDiff.addChild(BooleanDifference.construct("" + i, first[i], second[i])); } for (int i = firstLength; i < secondLength; i++) { totalDiff.addChild(BooleanDifference.construct("" + i, null, second[i])); } } else { for (int i = 0; i < secondLength; i++) { totalDiff.addChild(BooleanDifference.construct("" + i, first[i], second[i])); } for (int i = secondLength; i < firstLength; i++) { totalDiff.addChild(BooleanDifference.construct("" + i, first[i], null)); } } if (totalDiff.childCount() == 0) { return null; } return totalDiff; } private  BooleanArrayDifference(String name); static IDifference construct(String name, boolean[] first, boolean[] second); @Override String toString();  }
@Test public void testDiff() { IDifference result = BooleanArrayDifference.construct("Foo", new boolean[]{true, true}, new boolean[]{false, false}); Assert.assertNotNull(result); }
@Test public void testSame() { IDifference result = BooleanArrayDifference.construct("Foo", new boolean[]{false, false}, new boolean[]{false, false}); Assert.assertNull(result); }
@Test public void testTwoNull() { IDifference result = BooleanArrayDifference.construct("Foo", null, null); Assert.assertNull(result); }
@Test public void testOneNull() { IDifference result = BooleanArrayDifference.construct("Foo", null, new boolean[]{false, false}); Assert.assertNotNull(result); result = BooleanArrayDifference.construct("Foo", new boolean[]{false, false}, null); Assert.assertNotNull(result); }