diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-13 00:33:58 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-17 20:13:22 +0100 |
| commit | 0fdccaf9779b376938a1cd795f31f3bc5036333f (patch) | |
| tree | cfa86af70b411a7cdb71aad8f6b4a9c9fd724662 /test/test.cc | |
| parent | d460960876cfef9d8638843345fdc1db1294db73 (diff) | |
Remove 32x32 test image.
Diffstat (limited to 'test/test.cc')
| -rw-r--r-- | test/test.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/test/test.cc b/test/test.cc index 6617f513..9f285dbc 100644 --- a/test/test.cc +++ b/test/test.cc @@ -199,8 +199,8 @@ check_xml (string ref, string test, list<string> ignore, bool ignore_whitespace) void check_file (boost::filesystem::path ref, boost::filesystem::path check) { - uintmax_t N = boost::filesystem::file_size (ref); - BOOST_CHECK_EQUAL (N, boost::filesystem::file_size (check)); + uintmax_t size = boost::filesystem::file_size (ref); + BOOST_CHECK_EQUAL (size, boost::filesystem::file_size(check)); FILE* ref_file = dcp::fopen_boost (ref, "rb"); BOOST_REQUIRE (ref_file); FILE* check_file = dcp::fopen_boost (check, "rb"); @@ -210,22 +210,29 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) uint8_t* ref_buffer = new uint8_t[buffer_size]; uint8_t* check_buffer = new uint8_t[buffer_size]; - string error; - error = "File " + check.string() + " differs from reference " + ref.string(); + uintmax_t pos = 0; - while (N) { - uintmax_t this_time = min (uintmax_t (buffer_size), N); + while (pos < size) { + uintmax_t this_time = min (uintmax_t(buffer_size), size - pos); size_t r = fread (ref_buffer, 1, this_time, ref_file); BOOST_CHECK_EQUAL (r, this_time); r = fread (check_buffer, 1, this_time, check_file); BOOST_CHECK_EQUAL (r, this_time); - BOOST_CHECK_MESSAGE (memcmp (ref_buffer, check_buffer, this_time) == 0, error); - if (memcmp (ref_buffer, check_buffer, this_time)) { + if (memcmp(ref_buffer, check_buffer, this_time) != 0) { + for (int i = 0; i < buffer_size; ++i) { + if (ref_buffer[i] != check_buffer[i]) { + BOOST_CHECK_MESSAGE ( + false, + dcp::String::compose("File %1 differs from reference %2 at offset %3", check, ref, pos + i) + ); + break; + } + } break; } - N -= this_time; + pos += this_time; } delete[] ref_buffer; |
