|
@@ -16,9 +16,7 @@ static void testAdd(Test& test) {
|
|
|
|
|
|
static void testMultipleAdd(Test& test) {
|
|
static void testMultipleAdd(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(4);
|
|
|
|
- list.add(3);
|
|
|
|
- list.add(2);
|
|
|
|
|
|
+ list.add(4).add(3).add(2);
|
|
test.checkEqual(4, list[0], "list contains added value");
|
|
test.checkEqual(4, list[0], "list contains added value");
|
|
test.checkEqual(3, list[1], "list contains added value");
|
|
test.checkEqual(3, list[1], "list contains added value");
|
|
test.checkEqual(2, list[2], "list contains added value");
|
|
test.checkEqual(2, list[2], "list contains added value");
|
|
@@ -34,10 +32,7 @@ static void testAddReplace(Test& test) {
|
|
|
|
|
|
static void testClear(Test& test) {
|
|
static void testClear(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(5);
|
|
|
|
- list.add(4);
|
|
|
|
- list.clear();
|
|
|
|
-
|
|
|
|
|
|
+ list.add(5).add(4).clear();
|
|
test.checkEqual(0, list.getLength(), "list length is 0 after clear");
|
|
test.checkEqual(0, list.getLength(), "list length is 0 after clear");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,9 +49,7 @@ static void testOverflow(Test& test) {
|
|
|
|
|
|
static void testCopy(Test& test) {
|
|
static void testCopy(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(1);
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
|
|
+ list.add(1).add(2).add(3);
|
|
|
|
|
|
IntList copy(list);
|
|
IntList copy(list);
|
|
test.checkEqual(list.getLength(), copy.getLength(), "list copy has same length");
|
|
test.checkEqual(list.getLength(), copy.getLength(), "list copy has same length");
|
|
@@ -67,9 +60,7 @@ static void testCopy(Test& test) {
|
|
|
|
|
|
static void testCopyAssignment(Test& test) {
|
|
static void testCopyAssignment(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(1);
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
|
|
+ list.add(1).add(2).add(3);
|
|
|
|
|
|
IntList copy;
|
|
IntList copy;
|
|
copy = list;
|
|
copy = list;
|
|
@@ -81,9 +72,7 @@ static void testCopyAssignment(Test& test) {
|
|
|
|
|
|
static void testMove(Test& test) {
|
|
static void testMove(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(1);
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
|
|
+ list.add(1).add(2).add(3);
|
|
|
|
|
|
IntList move(std::move(list));
|
|
IntList move(std::move(list));
|
|
test.checkEqual(0, list.getLength(), "moved list has length 0");
|
|
test.checkEqual(0, list.getLength(), "moved list has length 0");
|
|
@@ -95,9 +84,7 @@ static void testMove(Test& test) {
|
|
|
|
|
|
static void testMoveAssignment(Test& test) {
|
|
static void testMoveAssignment(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(1);
|
|
|
|
- list.add(2);
|
|
|
|
- list.add(3);
|
|
|
|
|
|
+ list.add(1).add(2).add(3);
|
|
|
|
|
|
IntList move(std::move(list));
|
|
IntList move(std::move(list));
|
|
test.checkEqual(0, list.getLength(), "assignment moved list has length 0");
|
|
test.checkEqual(0, list.getLength(), "assignment moved list has length 0");
|
|
@@ -109,27 +96,19 @@ static void testMoveAssignment(Test& test) {
|
|
|
|
|
|
static void testToString1(Test& test) {
|
|
static void testToString1(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- list.add(1);
|
|
|
|
- list.add(243);
|
|
|
|
- list.add(-423);
|
|
|
|
- String s;
|
|
|
|
- s.append(list);
|
|
|
|
- test.checkEqual(String("[1, 243, -423]"), s, "list to string 1");
|
|
|
|
|
|
+ list.add(1).add(243).add(-423);
|
|
|
|
+ test.checkEqual(String("[1, 243, -423]"), String(list), "list to string 1");
|
|
}
|
|
}
|
|
|
|
|
|
static void testToString2(Test& test) {
|
|
static void testToString2(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
list.add(1);
|
|
list.add(1);
|
|
- String s;
|
|
|
|
- s.append(list);
|
|
|
|
- test.checkEqual(String("[1]"), s, "list to string 2");
|
|
|
|
|
|
+ test.checkEqual(String("[1]"), String(list), "list to string 2");
|
|
}
|
|
}
|
|
|
|
|
|
static void testToString3(Test& test) {
|
|
static void testToString3(Test& test) {
|
|
IntList list;
|
|
IntList list;
|
|
- String s;
|
|
|
|
- s.append(list);
|
|
|
|
- test.checkEqual(String("[]"), s, "list to string 3");
|
|
|
|
|
|
+ test.checkEqual(String("[]"), String(list), "list to string 3");
|
|
}
|
|
}
|
|
|
|
|
|
void ListTests::test() {
|
|
void ListTests::test() {
|