summaryrefslogtreecommitdiff
path: root/test/test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-02-28 00:36:04 +0100
committerCarl Hetherington <cth@carlh.net>2021-02-28 00:36:04 +0100
commit67544a255ffd7a27f5388e18cd0207f23ecce5ed (patch)
tree12367388cbf0d1ded1fea7ea05b1316de80a34d3 /test/test.cc
parent08cf432a8cc9bd0289e76bf684fb5264a7cfc7a7 (diff)
Try again to fix windows tests.
Diffstat (limited to 'test/test.cc')
-rw-r--r--test/test.cc38
1 files changed, 35 insertions, 3 deletions
diff --git a/test/test.cc b/test/test.cc
index 27393386b..8cbb2408b 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -445,13 +445,13 @@ check_image (boost::filesystem::path ref, boost::filesystem::path check, double
void
-check_file (boost::filesystem::path ref, boost::filesystem::path check, bool binary_mode)
+check_file (boost::filesystem::path ref, boost::filesystem::path check)
{
auto N = boost::filesystem::file_size (ref);
BOOST_CHECK_EQUAL (N, boost::filesystem::file_size (check));
- auto ref_file = fopen_boost (ref, binary_mode ? "rb" : "r");
+ auto ref_file = fopen_boost (ref, "rb");
BOOST_CHECK (ref_file);
- auto check_file = fopen_boost (check, binary_mode ? "rb" : "r");
+ auto check_file = fopen_boost (check, "rb");
BOOST_CHECK (check_file);
int const buffer_size = 65536;
@@ -483,6 +483,38 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check, bool bin
}
+void
+check_text_file (boost::filesystem::path ref, boost::filesystem::path check)
+{
+ auto ref_file = fopen_boost (ref, "r");
+ BOOST_CHECK (ref_file);
+ auto check_file = fopen_boost (check, "r");
+ BOOST_CHECK (check_file);
+
+ int const buffer_size = std::max(
+ boost::filesystem::file_size(ref),
+ boost::filesystem::file_size(check)
+ );
+
+ DCPOMATIC_ASSERT (buffer_size < 1024 * 1024);
+
+ auto ref_buffer = new uint8_t[buffer_size];
+ auto ref_read = fread(ref_buffer, 1, buffer_size, ref_file);
+ auto check_buffer = new uint8_t[buffer_size];
+ auto check_read = fread(check_buffer, 1, buffer_size, check_file);
+ BOOST_CHECK_EQUAL (ref_read, check_read);
+
+ string const error = "File " + check.string() + " differs from reference " + ref.string();
+ BOOST_CHECK_MESSAGE(memcmp(ref_buffer, check_buffer, ref_read) == 0, error);
+
+ delete[] ref_buffer;
+ delete[] check_buffer;
+
+ fclose (ref_file);
+ fclose (check_file);
+}
+
+
static void
note (dcp::NoteType t, string n)
{