summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/rtest.txt1
-rw-r--r--tests/test-Handles.cc16
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/rtest.txt b/tests/rtest.txt
new file mode 100644
index 0000000..7340463
--- /dev/null
+++ b/tests/rtest.txt
@@ -0,0 +1 @@
+Read test
diff --git a/tests/test-Handles.cc b/tests/test-Handles.cc
index 68d8baa..8c3c190 100644
--- a/tests/test-Handles.cc
+++ b/tests/test-Handles.cc
@@ -16,9 +16,10 @@ void MainTask::Do() {
failed = true;
}
Assert(failed);
- IO i(new Input("Makefile"));
+ IO i(new Input("tests/rtest.txt"));
Printer::log(M_STATUS, "Opened file %s:", i->getName());
Printer::log(M_STATUS, " - size = %lli", i->getSize());
+
char mtimestr[32];
time_t mtime = i->getMTime();
ctime_r(&mtime, mtimestr);
@@ -26,5 +27,18 @@ void MainTask::Do() {
if (nl)
*nl = 0;
Printer::log(M_STATUS, " - mtime = %i (%s)", mtime, mtimestr);
+
+ off_t s = i->rtell();
+ Assert(s == 0);
+
+ i->rseek(0, SEEK_END);
+ s = i->rtell();
+ 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);
+
Printer::log(M_STATUS, "Test::Handles passed.");
}