|
@@ -1,8 +1,10 @@
|
|
|
#include "tests/ListTests.h"
|
|
|
#include "tests/Test.h"
|
|
|
#include "utils/List.h"
|
|
|
+#include "utils/StringBuffer.h"
|
|
|
|
|
|
typedef List<int, 20> IntList;
|
|
|
+typedef StringBuffer<50> String;
|
|
|
|
|
|
static void testAdd(Test& test) {
|
|
|
IntList list;
|
|
@@ -105,6 +107,31 @@ static void testMoveAssignment(Test& test) {
|
|
|
test.checkEqual(3, move[2], "assignment moved list passes values");
|
|
|
}
|
|
|
|
|
|
+static void testToString1(Test& test) {
|
|
|
+ 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");
|
|
|
+}
|
|
|
+
|
|
|
+static void testToString2(Test& test) {
|
|
|
+ IntList list;
|
|
|
+ list.add(1);
|
|
|
+ String s;
|
|
|
+ s.append(list);
|
|
|
+ test.checkEqual(String("[1]"), s, "list to string 2");
|
|
|
+}
|
|
|
+
|
|
|
+static void testToString3(Test& test) {
|
|
|
+ IntList list;
|
|
|
+ String s;
|
|
|
+ s.append(list);
|
|
|
+ test.checkEqual(String("[]"), s, "list to string 3");
|
|
|
+}
|
|
|
+
|
|
|
void ListTests::test() {
|
|
|
Test test("List");
|
|
|
testAdd(test);
|
|
@@ -116,5 +143,8 @@ void ListTests::test() {
|
|
|
testCopyAssignment(test);
|
|
|
testMove(test);
|
|
|
testMoveAssignment(test);
|
|
|
+ testToString1(test);
|
|
|
+ testToString2(test);
|
|
|
+ testToString3(test);
|
|
|
test.finalize();
|
|
|
}
|