From 67b6a78b347ab7ba269a52d772e79d12444f6e96 Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 10 Oct 2011 23:09:53 -0700 Subject: Adding a few more features to Input, and actually creating a slightly better ClassName system, when using gcc and libstdc++. --- tests/rtest.txt | 1 + tests/test-Handles.cc | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/rtest.txt (limited to 'tests') 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."); } -- cgit v1.2.3