summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-28 16:43:28 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-28 16:43:28 +0100
commite4d5298e7a179d4103581cba05cbc516f94acf60 (patch)
tree0b9c8cb6ad65917f6a3bf76f5a55ec648bdb0e42 /test
parent5eb63969c5b6f26ea820cfab116d4aecb6bd3390 (diff)
parentdc52dfc8e5a5e89005098bbec56331f9f0c6d3aa (diff)
Merge branch '1.0' of git.carlh.net:git/libdcp into 1.0
Diffstat (limited to 'test')
-rw-r--r--test/colour_test.cc5
-rw-r--r--test/frame_info_hash_test.cc57
-rw-r--r--test/kdm_test.cc9
-rw-r--r--test/recovery_test.cc1
-rw-r--r--test/test.cc4
-rw-r--r--test/wscript1
6 files changed, 66 insertions, 11 deletions
diff --git a/test/colour_test.cc b/test/colour_test.cc
index a99b5b7e..d39c888d 100644
--- a/test/colour_test.cc
+++ b/test/colour_test.cc
@@ -19,10 +19,9 @@
#include "util.h"
#include "exceptions.h"
+#include <locked_sstream.h>
#include <boost/test/unit_test.hpp>
-using std::stringstream;
-
/** Check that dcp::Colour works */
BOOST_AUTO_TEST_CASE (colour)
{
@@ -58,7 +57,7 @@ BOOST_AUTO_TEST_CASE (colour)
BOOST_CHECK_THROW (dcp::Colour ("001234"), dcp::XMLError);
- stringstream s;
+ locked_stringstream s;
s << c;
BOOST_CHECK_EQUAL (s.str(), "(255, 0, 0)");
}
diff --git a/test/frame_info_hash_test.cc b/test/frame_info_hash_test.cc
new file mode 100644
index 00000000..1713963b
--- /dev/null
+++ b/test/frame_info_hash_test.cc
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+
+ This file is part of libdcp.
+
+ libdcp is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ libdcp is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libdcp. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "mono_picture_asset.h"
+#include "mono_picture_asset_writer.h"
+#include "j2k.h"
+#include "openjpeg_image.h"
+#include <boost/test/unit_test.hpp>
+
+using std::string;
+using boost::shared_ptr;
+
+static void
+check (unsigned int* seed, shared_ptr<dcp::PictureAssetWriter> writer, string hash)
+{
+ shared_ptr<dcp::OpenJPEGImage> xyz (new dcp::OpenJPEGImage (dcp::Size (1998, 1080)));
+ for (int c = 0; c < 3; ++c) {
+ for (int p = 0; p < (1998 * 1080); ++p) {
+ xyz->data(c)[p] = rand_r (seed);
+ }
+ }
+
+ dcp::Data data = dcp::compress_j2k (xyz, 100000000, 24, false, false);
+
+ dcp::FrameInfo info = writer->write (data.data().get(), data.size());
+ BOOST_CHECK_EQUAL (info.hash, hash);
+}
+
+/** Test the hashing of data written to JPEG2000 MXFs with some random inputs */
+BOOST_AUTO_TEST_CASE (frame_info_hash_test)
+{
+ shared_ptr<dcp::MonoPictureAsset> mp (new dcp::MonoPictureAsset (dcp::Fraction (24, 1)));
+ shared_ptr<dcp::PictureAssetWriter> writer = mp->start_write ("build/test/frame_info_hash_test.mxf", dcp::SMPTE, false);
+
+ unsigned int seed = 42;
+
+ /* Check a few random frames */
+ check (&seed, writer, "7ddfb4f5cec76f95138c4377a829dd6f");
+ check (&seed, writer, "d6a91028bab60995b4fc49fbccd5c2ba");
+ check (&seed, writer, "9d8653644f49f692e4bbac34106a4897");
+}
diff --git a/test/kdm_test.cc b/test/kdm_test.cc
index ee52ad8e..82701d96 100644
--- a/test/kdm_test.cc
+++ b/test/kdm_test.cc
@@ -17,14 +17,13 @@
along with libdcp. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <boost/test/unit_test.hpp>
-#include <libxml++/libxml++.h>
#include "encrypted_kdm.h"
#include "decrypted_kdm.h"
#include "util.h"
+#include <libxml++/libxml++.h>
+#include <boost/test/unit_test.hpp>
using std::list;
-using std::stringstream;
using boost::shared_ptr;
/** Check reading and decryption of a KDM */
@@ -58,9 +57,7 @@ BOOST_AUTO_TEST_CASE (kdm_passthrough_test)
);
shared_ptr<xmlpp::DomParser> parser (new xmlpp::DomParser ());
- stringstream s;
- s << kdm.as_xml ();
- parser->parse_stream (s);
+ parser->parse_memory (kdm.as_xml ());
parser->get_document()->write_to_file_formatted ("build/kdm.xml", "UTF-8");
int const r = system (
"xmldiff -c test/data/kdm_TONEPLATES-SMPTE-ENC_.smpte-430-2.ROOT.NOT_FOR_PRODUCTION_20130706_20230702_CAR_OV_t1_8971c838.xml build/kdm.xml"
diff --git a/test/recovery_test.cc b/test/recovery_test.cc
index 7482b8cc..6c4f6ac9 100644
--- a/test/recovery_test.cc
+++ b/test/recovery_test.cc
@@ -54,6 +54,7 @@ BOOST_AUTO_TEST_CASE (recovery)
int written_size = 0;
for (int i = 0; i < 24; ++i) {
dcp::FrameInfo info = writer->write (data, size);
+ BOOST_CHECK_EQUAL (info.hash, "cb90485a97ea5f7555cedc8a7afd473b");
written_size = info.size;
}
diff --git a/test/test.cc b/test/test.cc
index 0e7ad511..c17f1506 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -21,13 +21,13 @@
#define BOOST_TEST_MODULE libdcp_test
#include "util.h"
#include "test.h"
+#include <locked_sstream.h>
#include <libxml++/libxml++.h>
#include <boost/test/unit_test.hpp>
#include <cstdio>
using std::string;
using std::min;
-using std::stringstream;
using std::list;
boost::filesystem::path private_test;
@@ -123,7 +123,7 @@ check_file (boost::filesystem::path ref, boost::filesystem::path check)
uint8_t* ref_buffer = new uint8_t[buffer_size];
uint8_t* check_buffer = new uint8_t[buffer_size];
- stringstream error;
+ locked_stringstream error;
error << "File " << check.string() << " differs from reference " << ref.string();
while (N) {
diff --git a/test/wscript b/test/wscript
index 653ab09d..b56de9cb 100644
--- a/test/wscript
+++ b/test/wscript
@@ -75,6 +75,7 @@ def build(bld):
encryption_test.cc
exception_test.cc
fraction_test.cc
+ frame_info_hash_test.cc
gamma_transfer_function_test.cc
interop_load_font_test.cc
local_time_test.cc