### Question:
EnumValuePartitioner { public static List<BitGroup> partition(long[] values) { List<BitGroup> list = new LinkedList<>(); long totalMask = 0; for (long value : values) { totalMask |= value; BitGroup bitGroup = new BitGroup(value); merge(list, bitGroup); } list.add(new BitGroup(~totalMask)); return list; }  static List<BitGroup> partition(long[] values);  }### Answer:
@Test public void testDisjointValues() { List<BitGroup> list = EnumValuePartitioner.partition(new long[] { 1, 2, 4, 8 }); assertEquals(5, list.size()); }
@Test public void testAllOverlappingValues() { List<BitGroup> list = EnumValuePartitioner.partition(new long[] { 1, 2, 4, 8, 15 }); assertEquals(2, list.size()); BitGroup group = list.get(0); assertEquals(15, group.getMask()); Set<Long> values = group.getValues(); assertEquals(5, values.size()); assertTrue(values.contains(1L)); assertTrue(values.contains(2L)); assertTrue(values.contains(4L)); assertTrue(values.contains(8L)); assertTrue(values.contains(15L)); }
@Test public void testSomeOverlappingValues() { List<BitGroup> list = EnumValuePartitioner.partition(new long[] { 1, 2, 4, 8, 6 }); assertEquals(4, list.size()); assertEquals(1, list.get(0).getMask()); assertEquals(8, list.get(1).getMask()); assertEquals(6, list.get(2).getMask()); }