summaryrefslogtreecommitdiff
path: root/test/dcp_font_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-04-12 22:34:04 +0200
committerCarl Hetherington <cth@carlh.net>2022-04-12 22:34:04 +0200
commitc83f348adce3a18a9144ecfd73f4629cf060cc2a (patch)
tree5528c60440343b547c15f4a95aa6acd06453fafe /test/dcp_font_test.cc
parent04e215a7688239cb47fc86e8396756c685f338a1 (diff)
Add and use new File class.merged-to-main
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/dcp_font_test.cc')
-rw-r--r--test/dcp_font_test.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/test/dcp_font_test.cc b/test/dcp_font_test.cc
index 047e0266..361f5011 100644
--- a/test/dcp_font_test.cc
+++ b/test/dcp_font_test.cc
@@ -32,15 +32,16 @@
*/
-#include "interop_subtitle_asset.h"
-#include "smpte_subtitle_asset.h"
-#include "dcp.h"
#include "cpl.h"
-#include "test.h"
+#include "dcp.h"
+#include "file.h"
+#include "interop_subtitle_asset.h"
#include "reel.h"
-#include "util.h"
#include "reel_interop_subtitle_asset.h"
#include "reel_smpte_subtitle_asset.h"
+#include "smpte_subtitle_asset.h"
+#include "test.h"
+#include "util.h"
#include <boost/test/unit_test.hpp>
#include <cstdio>
@@ -81,11 +82,11 @@ BOOST_AUTO_TEST_CASE (interop_dcp_font_test)
BOOST_REQUIRE_EQUAL (subs2->_fonts.size(), 1);
auto const size = boost::filesystem::file_size ("test/data/dummy.ttf");
- auto f = dcp::fopen_boost ("test/data/dummy.ttf", "rb");
+ dcp::File f("test/data/dummy.ttf", "rb");
BOOST_REQUIRE (f);
shared_array<uint8_t> ref (new uint8_t[size]);
- fread (ref.get(), 1, size, f);
- fclose (f);
+ f.read(ref.get(), 1, size);
+ f.close();
BOOST_CHECK_EQUAL (memcmp (subs2->_fonts.front().data.data(), ref.get(), size), 0);
}
@@ -118,11 +119,11 @@ BOOST_AUTO_TEST_CASE (smpte_dcp_font_test)
BOOST_REQUIRE_EQUAL (subs2->_fonts.size(), 1);
auto const size = boost::filesystem::file_size ("test/data/dummy.ttf");
- auto f = dcp::fopen_boost ("test/data/dummy.ttf", "rb");
+ dcp::File f("test/data/dummy.ttf", "rb");
BOOST_REQUIRE (f);
shared_array<uint8_t> ref (new uint8_t[size]);
- fread (ref.get(), 1, size, f);
- fclose (f);
+ f.read(ref.get(), 1, size);
+ f.close();
BOOST_REQUIRE (subs2->_fonts.front().data.data());
BOOST_CHECK_EQUAL (memcmp (subs2->_fonts.front().data.data(), ref.get(), size), 0);