summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-10 23:09:53 -0700
committerPixel <pixel@nobis-crew.org>2011-10-10 23:31:07 -0700
commit67b6a78b347ab7ba269a52d772e79d12444f6e96 (patch)
tree5a105f61add7a5eaa8bd63a7182eecde84285b0e /tests
parent8ae349b49e16064e4d84b6cfd256e3ca7fb0cd60 (diff)
Adding a few more features to Input, and actually creating a slightly better ClassName system, when using gcc and libstdc++.
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.");
}