summaryrefslogtreecommitdiff
path: root/test/test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-31 14:19:50 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-31 14:19:50 +0100
commitf385ef03e5ea27519a31c0839447735a7fba0602 (patch)
tree310902e785a95c2e3be1ba389f29cd7bd480f2a2 /test/test.cc
parentc13771610ef9a01cb29342bca82f9999f8b5ddbc (diff)
Various stuff; mostly change to decoder scaling and adding subtitle; scaling test.
Diffstat (limited to 'test/test.cc')
-rw-r--r--test/test.cc64
1 files changed, 60 insertions, 4 deletions
diff --git a/test/test.cc b/test/test.cc
index 7d49bb66a..2837729c5 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -22,7 +22,8 @@
#include <boost/filesystem.hpp>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/date_time.hpp>
-#include "format.h"
+#include <libdcp/dcp.h>
+#include "ratio.h"
#include "film.h"
#include "filter.h"
#include "job_manager.h"
@@ -40,7 +41,6 @@
#include "ffmpeg_decoder.h"
#include "sndfile_decoder.h"
#include "dcp_content_type.h"
-#include "container.h"
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE dcpomatic_test
#include <boost/test/unit_test.hpp>
@@ -49,6 +49,8 @@ using std::string;
using std::list;
using std::stringstream;
using std::vector;
+using std::min;
+using std::cout;
using boost::shared_ptr;
using boost::thread;
using boost::dynamic_pointer_cast;
@@ -93,13 +95,67 @@ new_test_film (string name)
return f;
}
+void
+check_file (string ref, string check)
+{
+ uintmax_t N = boost::filesystem::file_size (ref);
+ BOOST_CHECK_EQUAL (N, boost::filesystem::file_size(check));
+ FILE* ref_file = fopen (ref.c_str(), "rb");
+ BOOST_CHECK (ref_file);
+ FILE* check_file = fopen (check.c_str(), "rb");
+ BOOST_CHECK (check_file);
+
+ int const buffer_size = 65536;
+ uint8_t* ref_buffer = new uint8_t[buffer_size];
+ uint8_t* check_buffer = new uint8_t[buffer_size];
+
+ while (N) {
+ uintmax_t this_time = min (uintmax_t (buffer_size), N);
+ 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_EQUAL (memcmp (ref_buffer, check_buffer, this_time), 0);
+ N -= this_time;
+ }
+
+ delete[] ref_buffer;
+ delete[] check_buffer;
+
+ fclose (ref_file);
+ fclose (check_file);
+}
+
+static void
+note (libdcp::NoteType, string n)
+{
+ cout << n << "\n";
+}
+
+void
+check_dcp (string ref, string check)
+{
+ libdcp::DCP ref_dcp (ref);
+ ref_dcp.read ();
+ libdcp::DCP check_dcp (check);
+ check_dcp.read ();
+
+ libdcp::EqualityOptions options;
+ options.max_mean_pixel_error = 5;
+ options.max_std_dev_pixel_error = 5;
+ options.max_audio_sample_error = 255;
+
+ BOOST_CHECK (ref_dcp.equals (check_dcp, options, boost::bind (note, _1, _2)));
+}
+
+
#include "scaling_test.cc"
-#include "container_test.cc"
+#include "ratio_test.cc"
#include "pixel_formats_test.cc"
#include "make_black_test.cc"
#include "film_metadata_test.cc"
#include "stream_test.cc"
-#include "format_test.cc"
#include "util_test.cc"
#include "dcp_test.cc"
#include "frame_rate_test.cc"