diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-18 23:24:01 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-10-18 23:24:01 +0000 |
commit | e0ef743090038ee02d656cee11debd2246624ba0 (patch) | |
tree | e5e1d32402c8dcb490c574e24c087c56d4cc172e /klm/util/file_piece_test.cc | |
parent | 0c2514868f58bbfe422aa275e2905182cf2f57eb (diff) |
kenneth's LM preliminary integration
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@681 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'klm/util/file_piece_test.cc')
-rw-r--r-- | klm/util/file_piece_test.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/klm/util/file_piece_test.cc b/klm/util/file_piece_test.cc new file mode 100644 index 00000000..befb7866 --- /dev/null +++ b/klm/util/file_piece_test.cc @@ -0,0 +1,41 @@ +#include "util/file_piece.hh" + +#define BOOST_TEST_MODULE FilePieceTest +#include <boost/test/unit_test.hpp> +#include <fstream> +#include <iostream> + +namespace util { +namespace { + +/* mmap implementation */ +BOOST_AUTO_TEST_CASE(MMapLine) { + std::fstream ref("file_piece.cc", std::ios::in); + FilePiece test("file_piece.cc", NULL, 1); + std::string ref_line; + while (getline(ref, ref_line)) { + StringPiece test_line(test.ReadLine()); + // I submitted a bug report to ICU: http://bugs.icu-project.org/trac/ticket/7924 + if (!test_line.empty() || !ref_line.empty()) { + BOOST_CHECK_EQUAL(ref_line, test_line); + } + } +} + +/* read() implementation */ +BOOST_AUTO_TEST_CASE(ReadLine) { + std::fstream ref("file_piece.cc", std::ios::in); + FilePiece test("file_piece.cc", NULL, 1); + test.ForceFallbackToRead(); + std::string ref_line; + while (getline(ref, ref_line)) { + StringPiece test_line(test.ReadLine()); + // I submitted a bug report to ICU: http://bugs.icu-project.org/trac/ticket/7924 + if (!test_line.empty() || !ref_line.empty()) { + BOOST_CHECK_EQUAL(ref_line, test_line); + } + } +} + +} // namespace +} // namespace util |