aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qutil.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2020-01-12 15:48:22 +0100
committerJay Berkenbilt <ejb@ql.org>2020-01-13 15:19:53 +0100
commit9a398504ca869e00de15c713108264e0beead504 (patch)
tree23b10049734b6d2097444f7117856058cf110fdf /libtests/qutil.cc
parent752416554086d5d34323bc14164d5084db83cfbd (diff)
downloadqpdf-9a398504ca869e00de15c713108264e0beead504.tar.zst
Refactor QUtil::read_lines_from_file
This commit adds the preserve_eol flags but doesn't implement EOL preservation yet.
Diffstat (limited to 'libtests/qutil.cc')
-rw-r--r--libtests/qutil.cc10
1 files changed, 10 insertions, 0 deletions
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 <string.h>
#include <limits.h>
#include <assert.h>
+#include <fstream>
#ifdef _WIN32
# include <io.h>
@@ -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<char> buf;
size_t size = 0;
QUtil::read_file_into_memory("other-file", buf, size);