From 9a398504ca869e00de15c713108264e0beead504 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 12 Jan 2020 09:48:22 -0500 Subject: Refactor QUtil::read_lines_from_file This commit adds the preserve_eol flags but doesn't implement EOL preservation yet. --- libtests/qutil.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libtests/qutil.cc') diff --git a/libtests/qutil.cc b/libtests/qutil.cc index 3c87cd31..0331d715 100644 --- a/libtests/qutil.cc +++ b/libtests/qutil.cc @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef _WIN32 # include @@ -408,6 +409,15 @@ void read_from_file_test() { std::cout << *iter << std::endl; } + // Test the other versions and make sure we get the same results + { + std::ifstream infs("other-file", std::ios_base::binary); + assert(QUtil::read_lines_from_file(infs) == lines); + FILE* fp = QUtil::safe_fopen("other-file", "rb"); + assert(QUtil::read_lines_from_file(fp) == lines); + fclose(fp); + } + PointerHolder buf; size_t size = 0; QUtil::read_file_into_memory("other-file", buf, size); -- cgit v1.2.3-70-g09d2