summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dcp_font_test.cc23
-rw-r--r--test/test.cc12
-rw-r--r--test/verify_test.cc26
3 files changed, 31 insertions, 30 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);
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);
}
diff --git a/test/verify_test.cc b/test/verify_test.cc
index 4b4aeea7..23b96c32 100644
--- a/test/verify_test.cc
+++ b/test/verify_test.cc
@@ -31,9 +31,11 @@
files in the program, then also delete it here.
*/
+
#include "compose.hpp"
#include "cpl.h"
#include "dcp.h"
+#include "file.h"
#include "interop_subtitle_asset.h"
#include "j2k_transcode.h"
#include "mono_picture_asset.h"
@@ -63,14 +65,14 @@
using std::list;
+using std::make_pair;
+using std::make_shared;
using std::pair;
+using std::shared_ptr;
using std::string;
using std::vector;
-using std::make_pair;
-using std::make_shared;
using boost::optional;
using namespace boost::filesystem;
-using std::shared_ptr;
static list<pair<string, optional<path>>> stages;
@@ -1392,10 +1394,10 @@ BOOST_AUTO_TEST_CASE (verify_missing_subtitle_language)
"</SubtitleList>"
"</SubtitleReel>";
- auto xml_file = dcp::fopen_boost (dir / "subs.xml", "w");
+ dcp::File xml_file(dir / "subs.xml", "w");
BOOST_REQUIRE (xml_file);
- fwrite (xml.c_str(), xml.size(), 1, xml_file);
- fclose (xml_file);
+ xml_file.write(xml.c_str(), xml.size(), 1);
+ xml_file.close();
auto subs = make_shared<dcp::SMPTESubtitleAsset>(dir / "subs.xml");
subs->write (dir / "subs.mxf");
@@ -1527,10 +1529,10 @@ BOOST_AUTO_TEST_CASE (verify_missing_subtitle_start_time)
"</SubtitleList>"
"</SubtitleReel>";
- auto xml_file = dcp::fopen_boost (dir / "subs.xml", "w");
+ dcp::File xml_file(dir / "subs.xml", "w");
BOOST_REQUIRE (xml_file);
- fwrite (xml.c_str(), xml.size(), 1, xml_file);
- fclose (xml_file);
+ xml_file.write(xml.c_str(), xml.size(), 1);
+ xml_file.close();
auto subs = make_shared<dcp::SMPTESubtitleAsset>(dir / "subs.xml");
subs->write (dir / "subs.mxf");
@@ -1580,10 +1582,10 @@ BOOST_AUTO_TEST_CASE (verify_invalid_subtitle_start_time)
"</SubtitleList>"
"</SubtitleReel>";
- auto xml_file = dcp::fopen_boost (dir / "subs.xml", "w");
+ dcp::File xml_file(dir / "subs.xml", "w");
BOOST_REQUIRE (xml_file);
- fwrite (xml.c_str(), xml.size(), 1, xml_file);
- fclose (xml_file);
+ xml_file.write(xml.c_str(), xml.size(), 1);
+ xml_file.close();
auto subs = make_shared<dcp::SMPTESubtitleAsset>(dir / "subs.xml");
subs->write (dir / "subs.mxf");