### Question:
MoreArrays { public static int deduplicate(final long[] data, final int start, final int end) { if (start == end) { return end; } int pos = start + 1; for (int i = pos; i < end; i++) { if (data[i] != data[i - 1]) { if (i != pos) { data[pos] = data[i]; } pos++; } } return pos; } private  MoreArrays(); static boolean isSorted(final long[] data, final int start, final int end); static int deduplicate(final long[] data, final int start, final int end); static int deduplicate(final int[] data, final int start, final int end);  }### Answer:
@Test public void testDeduplicateEmpty() { long[] data = {}; int end = MoreArrays.deduplicate(data, 0, 0); assertEquals(0, end); }
@Test public void testDeduplicateNoChange() { long[] data = {1, 2, 3}; int end = MoreArrays.deduplicate(data, 0, 3); assertEquals(3, end); assertThat(data, equalTo(new long[]{1, 2, 3})); }
@Test public void testDeduplicateDups() { long[] data = {1, 2, 2, 3}; int end = MoreArrays.deduplicate(data, 0, 4); assertEquals(3, end); assertEquals(1, data[0]); assertEquals(2, data[1]); assertEquals(3, data[2]); }
@Test public void testDeduplicateDupsEnd() { long[] data = {1, 2, 2, 3, 3}; int end = MoreArrays.deduplicate(data, 0, 5); assertEquals(3, end); assertEquals(1, data[0]); assertEquals(2, data[1]); assertEquals(3, data[2]); }