aboutsummaryrefslogtreecommitdiff
path: root/test/common
diff options
context:
space:
mode:
authorMax Horn2008-09-06 16:46:28 +0000
committerMax Horn2008-09-06 16:46:28 +0000
commit6cb09e311a6c02a5507b252b3b6661350f7cfa95 (patch)
treec61aaa45592825f26dffa424907821c3f5c6f6b0 /test/common
parent5756308ceca9454bcb043850d25af54eb0d48550 (diff)
downloadscummvm-rg350-6cb09e311a6c02a5507b252b3b6661350f7cfa95.tar.gz
scummvm-rg350-6cb09e311a6c02a5507b252b3b6661350f7cfa95.tar.bz2
scummvm-rg350-6cb09e311a6c02a5507b252b3b6661350f7cfa95.zip
Added some unit tests for Stream::readLine_NEW, and clarified that readLine_NEW is essentially fgets in disguise
svn-id: r34384
Diffstat (limited to 'test/common')
-rw-r--r--test/common/stream.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/common/stream.h b/test/common/stream.h
new file mode 100644
index 0000000000..99e70d3a50
--- /dev/null
+++ b/test/common/stream.h
@@ -0,0 +1,42 @@
+#include <cxxtest/TestSuite.h>
+
+#include "common/stream.h"
+
+class ReadLineStreamTestSuite : public CxxTest::TestSuite {
+ public:
+ void test_readline(void) {
+ byte contents[] = { 'a', 'b', '\n', '\n', 'c', '\n' };
+ Common::MemoryReadStream ms(contents, sizeof(contents));
+
+ char buffer[100];
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "ab\n"));
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "\n"));
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "c\n"));
+
+ TS_ASSERT(ms.eos());
+ }
+
+ void test_readline2(void) {
+ byte contents[] = { 'a', 'b', '\n', '\n', 'c' };
+ Common::MemoryReadStream ms(contents, sizeof(contents));
+
+ char buffer[100];
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "ab\n"));
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "\n"));
+
+ TS_ASSERT(0 != ms.readLine_NEW(buffer, sizeof(buffer)));
+ TS_ASSERT(0 == strcmp(buffer, "c"));
+
+ TS_ASSERT(ms.eos());
+ }
+};