|
@@ -37,6 +37,18 @@ static void testClear(Test& test) {
|
|
|
test.checkEqual(0, list.getLength(), "length is 0 after clear");
|
|
|
}
|
|
|
|
|
|
+static void testShrink(Test& test) {
|
|
|
+ IntList list;
|
|
|
+ list.add(5).add(4).add(3);
|
|
|
+ test.checkTrue(list.getCapacity() >= 3, "capacity is >= 3 after adding");
|
|
|
+ list.shrink();
|
|
|
+ test.checkTrue(list.getLength() == 3, "length is 3 after shrink");
|
|
|
+ test.checkTrue(list.getCapacity() == 3, "capacity is 3 after shrink");
|
|
|
+ test.checkEqual(5, list[0], "data ok after shrink 1");
|
|
|
+ test.checkEqual(4, list[1], "data ok after shrink 2");
|
|
|
+ test.checkEqual(3, list[2], "data ok after shrink 3");
|
|
|
+}
|
|
|
+
|
|
|
static void testBigAdd(Test& test) {
|
|
|
IntList list;
|
|
|
for(int i = 0; i < 1000000; i++) {
|
|
@@ -148,6 +160,7 @@ void ListTests::test() {
|
|
|
testMultipleAdd(test);
|
|
|
testAddReplace(test);
|
|
|
testClear(test);
|
|
|
+ testShrink(test);
|
|
|
testBigAdd(test);
|
|
|
testCopy(test);
|
|
|
testCopyAssignment(test);
|