|
|
@@ -94,7 +94,8 @@ public final class SortedMapTester<K,V> {
|
|
|
checkSub(true, target, $map.list(3,4,5,6,7).keys());
|
|
|
}
|
|
|
|
|
|
- private void checkHead(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
+ @SafeVarargs
|
|
|
+ final void checkHead(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
int n = content.length;
|
|
|
assertEquals(0, target.headMap($map.item(0).key()).size());
|
|
|
assertEquals(n, target.headMap($map.item(9).key()).size());
|
|
|
@@ -102,7 +103,7 @@ public final class SortedMapTester<K,V> {
|
|
|
|
|
|
for(int i=0; i<n; i++) {
|
|
|
K point = content[i];
|
|
|
- K[] exp = ArrayUtils.head(content, point);
|
|
|
+ K[] exp = ArrayUtils.head(content, point, $map.comparator());
|
|
|
SortedMap<K, V> map = target.headMap(point);
|
|
|
assertEquals(exp.length, map.size());
|
|
|
if(nested) {
|
|
|
@@ -113,7 +114,8 @@ public final class SortedMapTester<K,V> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void checkTail(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
+ @SafeVarargs
|
|
|
+ final void checkTail(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
int n = content.length;
|
|
|
assertEquals(n, target.tailMap($map.item(0).key()).size());
|
|
|
assertEquals(0, target.tailMap($map.item(9).key()).size());
|
|
|
@@ -121,7 +123,7 @@ public final class SortedMapTester<K,V> {
|
|
|
|
|
|
for(int i=0; i<n; i++) {
|
|
|
K point = content[i];
|
|
|
- K[] exp = ArrayUtils.tail(content, point);
|
|
|
+ K[] exp = ArrayUtils.tail(content, point, $map.comparator());
|
|
|
SortedMap<K, V> map = target.tailMap(point);
|
|
|
assertEquals(exp.length, map.size());
|
|
|
if(nested) {
|
|
|
@@ -132,7 +134,8 @@ public final class SortedMapTester<K,V> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void checkSub(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
+ @SafeVarargs
|
|
|
+ final void checkSub(boolean nested, SortedMap<K, V> target, K... content) {
|
|
|
checkSub(nested, target, $map.item(3), $map.item(9), content);
|
|
|
checkSub(nested, target, $map.item(5), $map.item(9), content);
|
|
|
|
|
|
@@ -150,7 +153,7 @@ public final class SortedMapTester<K,V> {
|
|
|
}
|
|
|
|
|
|
private void checkSub(boolean nested, SortedMap<K, V> target, TItem<K,V> begin, TItem<K,V> end, K[] content) {
|
|
|
- K[] exp = ArrayUtils.slice(content, begin.key(), end.key());
|
|
|
+ K[] exp = ArrayUtils.slice(content, begin.key(), end.key(), $map.comparator());
|
|
|
|
|
|
SortedMap<K, V> map = target.subMap(begin.key(), end.key());
|
|
|
assertEquals(exp.length, map.size());
|
|
|
@@ -219,13 +222,13 @@ public final class SortedMapTester<K,V> {
|
|
|
@Test
|
|
|
public void basicIterator(SortedMap<K, V> target) {
|
|
|
TItems<K,V> list1 = $map.list();
|
|
|
- TItems<K,V> list2 = $map.list(4, 7, 5, 3, 6);
|
|
|
+ TItems<K,V> list2 = $map.list(3, 4, 5, 6, 7);
|
|
|
|
|
|
IteratorTester.basicIterator((ListIterator)target.keySet().iterator(), 0, list1.keys());
|
|
|
IteratorTester.basicIterator((ListIterator)target.entrySet().iterator(), 0, list1.entries());
|
|
|
IteratorTester.basicIterator((ListIterator)target.values().iterator(), 0, list1.values());
|
|
|
|
|
|
- list2.into(target);
|
|
|
+ $map.list(4, 7, 5, 3, 6).into(target);
|
|
|
|
|
|
IteratorTester.basicIterator((ListIterator)target.keySet().iterator(), 0, list2.keys());
|
|
|
IteratorTester.basicIterator((ListIterator)target.entrySet().iterator(), 0, list2.entries());
|
|
|
@@ -236,7 +239,7 @@ public final class SortedMapTester<K,V> {
|
|
|
@Test
|
|
|
public void basicIteratorFrom(SortedMap<K, V> target) {
|
|
|
TItems<K,V> list1 = $map.list();
|
|
|
- TItems<K,V> list2 = $map.list(4, 7, 5, 3, 6);
|
|
|
+ TItems<K,V> list2 = $map.list(3, 4, 5, 6, 7);
|
|
|
TItem<K,V> item = $map.item(4);
|
|
|
|
|
|
IteratorTester.basicIterator((ListIterator)sort(target.keySet()).iterator(item.key()), 0, list1.keys());
|
|
|
@@ -291,7 +294,7 @@ public final class SortedMapTester<K,V> {
|
|
|
@Test
|
|
|
public void basicSubMap_Remove(SortedMap<K, V> target) {
|
|
|
$map.list(4, 7, 5, 3, 6).into(target);
|
|
|
- SortedMap<K, V> map = target.subMap($map.item(4).key(), $map.item(6).key());
|
|
|
+ SortedMap<K, V> map = target.subMap($map.item(4).key(), $map.item(7).key());
|
|
|
assertEquals(5, target.size());
|
|
|
assertEquals(3, map.size());
|
|
|
|
|
|
@@ -319,7 +322,14 @@ public final class SortedMapTester<K,V> {
|
|
|
@Test
|
|
|
public void basicToString(SortedMap<K, V> target) {
|
|
|
$map.list(2,5,1,3,4).into(target);
|
|
|
- assertEquals("{(7:4:6)=>17, (8:4:12)=>21, (9:4:13)=>22, (20:40:3)=>31, (33:42:6)=>81}", target.toString());
|
|
|
+ String expected = "{"
|
|
|
+ + $map.item(1).key() + "=>" + $map.item(1).value() + ", "
|
|
|
+ + $map.item(2).key() + "=>" + $map.item(2).value() + ", "
|
|
|
+ + $map.item(3).key() + "=>" + $map.item(3).value() + ", "
|
|
|
+ + $map.item(4).key() + "=>" + $map.item(4).value() + ", "
|
|
|
+ + $map.item(5).key() + "=>" + $map.item(5).value()
|
|
|
+ + "}";
|
|
|
+ assertEquals(expected, target.toString());
|
|
|
}
|
|
|
|
|
|
}
|