MapList ml2 = new MapList(new int[] { 15, 16 }, new int[] { 58, 53 }, 1,
3);
ml.addMapList(ml2);
- assertEquals("[ [11, 16] ] 1:3 to [ [72, 53] ]", ml.toString());
+ assertEquals("[ [11, 15] [15, 16] ] 1:3 to [ [72, 58] [58, 53] ]", ml.toString());
+
+ MapList ml3 = new MapList(new int[] { 11, 15 }, new int[] { 72, 58 }, 1,
+ 3);
+
+ MapList ml4 = new MapList(new int[] { 15, 16 }, new int[] { 1, 6 }, 1,
+ 3);
+ ml3.addMapList(ml4);
+ assertEquals("[ [11, 15] [15, 16] ] 1:3 to [ [72, 58] [1, 6] ]", ml3.toString());
}
@Test(groups = "Functional")
assertEquals(1, ranges.size());
assertSame(range, ranges.get(0));
- // extend contiguous (same position):
+ // extend overlapping (same position):
MapList.addRange(new int[] { 5, 10 }, ranges);
- assertEquals(1, ranges.size());
+ assertEquals(2, ranges.size());
assertEquals(1, ranges.get(0)[0]);
- assertEquals(10, ranges.get(0)[1]);
+ assertEquals(5, ranges.get(0)[1]);
+ assertEquals(5, ranges.get(1)[0]);
+ assertEquals(10, ranges.get(1)[1]);
// extend contiguous (next position):
MapList.addRange(new int[] { 11, 15 }, ranges);
- assertEquals(1, ranges.size());
+ assertEquals(2, ranges.size());
assertEquals(1, ranges.get(0)[0]);
- assertEquals(15, ranges.get(0)[1]);
+ assertEquals(5, ranges.get(0)[1]);
+ assertEquals(5, ranges.get(1)[0]);
+ assertEquals(15, ranges.get(1)[1]);
// change direction: range is not merged:
MapList.addRange(new int[] { 16, 10 }, ranges);
- assertEquals(2, ranges.size());
- assertEquals(16, ranges.get(1)[0]);
- assertEquals(10, ranges.get(1)[1]);
+ assertEquals(3, ranges.size());
+ assertEquals(16, ranges.get(2)[0]);
+ assertEquals(10, ranges.get(2)[1]);
- // extend reverse contiguous (same position):
+ // extend reverse overlapping (same position):
MapList.addRange(new int[] { 10, 8 }, ranges);
- assertEquals(2, ranges.size());
- assertEquals(16, ranges.get(1)[0]);
- assertEquals(8, ranges.get(1)[1]);
+ assertEquals(4, ranges.size());
+ assertEquals(10, ranges.get(3)[0]);
+ assertEquals(8, ranges.get(3)[1]);
// extend reverse contiguous (next position):
MapList.addRange(new int[] { 7, 6 }, ranges);
- assertEquals(2, ranges.size());
- assertEquals(16, ranges.get(1)[0]);
- assertEquals(6, ranges.get(1)[1]);
+ assertEquals(4, ranges.size());
+ assertEquals(10, ranges.get(3)[0]);
+ assertEquals(6, ranges.get(3)[1]);
// change direction: range is not merged:
MapList.addRange(new int[] { 6, 9 }, ranges);
- assertEquals(3, ranges.size());
- assertEquals(6, ranges.get(2)[0]);
- assertEquals(9, ranges.get(2)[1]);
+ assertEquals(5, ranges.size());
+ assertEquals(6, ranges.get(4)[0]);
+ assertEquals(9, ranges.get(4)[1]);
// not contiguous: not merged
MapList.addRange(new int[] { 11, 12 }, ranges);
- assertEquals(4, ranges.size());
- assertEquals(11, ranges.get(3)[0]);
- assertEquals(12, ranges.get(3)[1]);
+ assertEquals(6, ranges.size());
+ assertEquals(11, ranges.get(5)[0]);
+ assertEquals(12, ranges.get(5)[1]);
}
/**