summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-11 00:47:18 -0700
committerPixel <pixel@nobis-crew.org>2011-10-11 00:47:18 -0700
commitd2252afcd74af0248c6141c8086d03e12a0a316f (patch)
tree43ba0cca065d205fa1b9fa5810de1481948aaad5 /tests
parent67b6a78b347ab7ba269a52d772e79d12444f6e96 (diff)
Input class seems to be done.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-Handles.cc20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test-Handles.cc b/tests/test-Handles.cc
index 8c3c190..36ad998 100644
--- a/tests/test-Handles.cc
+++ b/tests/test-Handles.cc
@@ -12,7 +12,7 @@ void MainTask::Do() {
try {
IO i(new Input("SomeInexistantFile.txt"));
}
- catch (GeneralException) {
+ catch (ENoEnt e) {
failed = true;
}
Assert(failed);
@@ -36,9 +36,21 @@ void MainTask::Do() {
Assert(s == i->getSize());
i->rseek(0, SEEK_SET);
- char * buf = (char *) malloc(i->getSize());
- ssize_t r = i->read(buf, s + 15);
- Printer::log(M_STATUS, "Read %i bytes", r);
+ char * buf1 = (char *) malloc(i->getSize());
+ ssize_t r = i->read(buf1, s + 15);
+ Printer::log(M_STATUS, "Read %i bytes (instead of %i)", r, s + 15);
+ Assert(i->isEOF())
+
+ char * buf2 = (char *) malloc(i->getSize());
+ i->rseek(0, SEEK_SET);
+ Assert(!i->isEOF());
+ Assert(i->rtell() == 0);
+ r = i->read(buf2, 5);
+ Assert(r == 5);
+ Assert(i->rtell() == 5);
+ r = i->read(buf2 + 5, s - 5);
+ Assert(r == (s - 5));
+ Assert(memcmp(buf1, buf2, s) == 0);
Printer::log(M_STATUS, "Test::Handles passed.");
}