diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-04-12 22:34:04 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-20 20:04:21 +0200 |
| commit | 05bfa3d1fe9e274ed195647c6f74cb272f00c23d (patch) | |
| tree | 1372760463b288ff4e10ef7fb6e7414e202829f5 /test/test.cc | |
| parent | 0338e7a7c19617f9ebb64ee02fbf3cceab8cf03f (diff) | |
Add and use new File class.master
It was always a bit troubling that fopen_boost wasn't exception safe,
and this also fixes a leak where load_ratings_list would never close
the ratings file.
Diffstat (limited to 'test/test.cc')
| -rw-r--r-- | test/test.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/test/test.cc b/test/test.cc index 1b0b9b10..e1a7e84e 100644 --- a/test/test.cc +++ b/test/test.cc @@ -37,6 +37,7 @@ #include "cpl.h" #include "dcp.h" #include "interop_subtitle_asset.h" +#include "file.h" #include "j2k_transcode.h" #include "mono_picture_asset.h" #include "mono_picture_asset.h" @@ -210,9 +211,9 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) { uintmax_t size = boost::filesystem::file_size (ref); BOOST_CHECK_EQUAL (size, boost::filesystem::file_size(check)); - auto ref_file = dcp::fopen_boost (ref, "rb"); + dcp::File ref_file(ref, "rb"); BOOST_REQUIRE (ref_file); - auto check_file = dcp::fopen_boost (check, "rb"); + dcp::File check_file(check, "rb"); BOOST_REQUIRE (check_file); int const buffer_size = 65536; @@ -223,9 +224,9 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) 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); + size_t r = ref_file.read(ref_buffer, 1, this_time); BOOST_CHECK_EQUAL (r, this_time); - r = fread (check_buffer, 1, this_time, check_file); + r = check_file.read(check_buffer, 1, this_time); BOOST_CHECK_EQUAL (r, this_time); if (memcmp(ref_buffer, check_buffer, this_time) != 0) { @@ -246,9 +247,6 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check) delete[] ref_buffer; delete[] check_buffer; - - fclose (ref_file); - fclose (check_file); } |
