summaryrefslogtreecommitdiff
path: root/klm/util/file_piece_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'klm/util/file_piece_test.cc')
-rw-r--r--klm/util/file_piece_test.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/klm/util/file_piece_test.cc b/klm/util/file_piece_test.cc
index f912e18a..7336007d 100644
--- a/klm/util/file_piece_test.cc
+++ b/klm/util/file_piece_test.cc
@@ -1,6 +1,7 @@
// Tests might fail if you have creative characters in your path. Sue me.
#include "util/file_piece.hh"
+#include "util/file.hh"
#include "util/scoped.hh"
#define BOOST_TEST_MODULE FilePieceTest
@@ -23,6 +24,20 @@ std::string FileLocation() {
return ret;
}
+/* istream */
+BOOST_AUTO_TEST_CASE(IStream) {
+ std::fstream ref(FileLocation().c_str(), std::ios::in);
+ std::fstream backing(FileLocation().c_str(), std::ios::in);
+ FilePiece test(backing);
+ std::string ref_line;
+ while (getline(ref, ref_line)) {
+ StringPiece test_line(test.ReadLine());
+ BOOST_CHECK_EQUAL(ref_line, test_line);
+ }
+ BOOST_CHECK_THROW(test.get(), EndOfFileException);
+ BOOST_CHECK_THROW(test.get(), EndOfFileException);
+}
+
/* mmap implementation */
BOOST_AUTO_TEST_CASE(MMapReadLine) {
std::fstream ref(FileLocation().c_str(), std::ios::in);
@@ -38,7 +53,7 @@ BOOST_AUTO_TEST_CASE(MMapReadLine) {
BOOST_CHECK_THROW(test.get(), EndOfFileException);
}
-#ifndef __APPLE__
+#if !defined(_WIN32) && !defined(_WIN64) && !defined(__APPLE__)
/* Apple isn't happy with the popen, fileno, dup. And I don't want to
* reimplement popen. This is an issue with the test.
*/
@@ -65,7 +80,7 @@ BOOST_AUTO_TEST_CASE(StreamReadLine) {
BOOST_CHECK_THROW(test.get(), EndOfFileException);
BOOST_REQUIRE(!pclose(catter));
}
-#endif // __APPLE__
+#endif
#ifdef HAVE_ZLIB