From 05bfa3d1fe9e274ed195647c6f74cb272f00c23d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Apr 2022 22:34:04 +0200 Subject: Add and use new File class. 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. --- test/dcp_font_test.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test/dcp_font_test.cc') 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 #include @@ -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 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 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); -- cgit v1.2.3