summaryrefslogtreecommitdiff
path: root/klm/util/file_piece_test.cc
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2013-01-22 21:37:49 +0000
committerKenneth Heafield <github@kheafield.com>2013-01-22 21:37:49 +0000
commit516c132fb683b5bf77ae3230a1b3709beb57618e (patch)
treed37fb5d1d8f4273dac3509291495ff9797c399e0 /klm/util/file_piece_test.cc
parent53532304714256f692fd5f7305b2fab10a7d7cca (diff)
KenLM 58da338b
Diffstat (limited to 'klm/util/file_piece_test.cc')
-rw-r--r--klm/util/file_piece_test.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/klm/util/file_piece_test.cc b/klm/util/file_piece_test.cc
index 91e4c559..7336007d 100644
--- a/klm/util/file_piece_test.cc
+++ b/klm/util/file_piece_test.cc
@@ -24,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);