|
@@ -114,17 +114,31 @@ static void testToString3(Test& test) {
|
|
|
test.checkEqual(String("[]"), String(list), "to string 3");
|
|
|
}
|
|
|
|
|
|
-static void testRemove(Test& test) {
|
|
|
+static void testRemoveBySwap(Test& test) {
|
|
|
IntList list;
|
|
|
list.add(4).add(3).add(2);
|
|
|
list.removeBySwap(0);
|
|
|
- test.checkEqual(2, list[0], "remove 1");
|
|
|
- test.checkEqual(3, list[1], "remove 2");
|
|
|
- test.checkEqual(2, list.getLength(), "remove 3");
|
|
|
+ test.checkEqual(2, list[0], "remove by swap 1");
|
|
|
+ test.checkEqual(3, list[1], "remove by swap 2");
|
|
|
+ test.checkEqual(2, list.getLength(), "remove by swap 3");
|
|
|
list.removeBySwap(1);
|
|
|
- test.checkEqual(2, list[0], "remove 4");
|
|
|
- test.checkEqual(1, list.getLength(), "remove 5");
|
|
|
+ test.checkEqual(2, list[0], "remove by swap 4");
|
|
|
+ test.checkEqual(1, list.getLength(), "remove by swap 5");
|
|
|
list.removeBySwap(0);
|
|
|
+ test.checkEqual(0, list.getLength(), "remove by swap 6");
|
|
|
+}
|
|
|
+
|
|
|
+static void testRemove(Test& test) {
|
|
|
+ IntList list;
|
|
|
+ list.add(4).add(3).add(2);
|
|
|
+ list.remove(0);
|
|
|
+ test.checkEqual(3, list[0], "remove 1");
|
|
|
+ test.checkEqual(2, list[1], "remove 2");
|
|
|
+ test.checkEqual(2, list.getLength(), "remove 3");
|
|
|
+ list.remove(1);
|
|
|
+ test.checkEqual(3, list[0], "remove 4");
|
|
|
+ test.checkEqual(1, list.getLength(), "remove 5");
|
|
|
+ list.remove(0);
|
|
|
test.checkEqual(0, list.getLength(), "remove 6");
|
|
|
}
|
|
|
|
|
@@ -142,6 +156,7 @@ void ListTests::test() {
|
|
|
testToString1(test);
|
|
|
testToString2(test);
|
|
|
testToString3(test);
|
|
|
+ testRemoveBySwap(test);
|
|
|
testRemove(test);
|
|
|
test.finalize();
|
|
|
}
|