summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-06-08 23:28:17 +0100
committerCarl Hetherington <cth@carlh.net>2015-06-08 23:28:17 +0100
commit6425742f95a4c2e539061b29016a4a5bd10ac9ae (patch)
tree9dd986f6ca187071811b7b94f3e5dc4e08c71988 /test
parent635c3ae7aee1cad4b871fcf0ddf02a8be1cdce78 (diff)
parent9e871b60fc7430650f239cfd9291ab65cb5aeba8 (diff)
Merge branch '1.0' of ssh://main.carlh.net/home/carl/git/libdcp into 1.0
Diffstat (limited to 'test')
-rw-r--r--test/certificates_test.cc1
-rw-r--r--test/colour_conversion_test.cc2
-rw-r--r--test/colour_test.cc2
-rw-r--r--test/cpl_sar_test.cc6
-rw-r--r--test/dcp_test.cc4
-rw-r--r--test/encryption_test.cc8
-rw-r--r--test/exception_test.cc1
-rw-r--r--test/fraction_test.cc1
-rw-r--r--test/interop_load_font_test.cc2
-rw-r--r--test/kdm_test.cc3
-rw-r--r--test/read_dcp_test.cc2
-rw-r--r--test/read_interop_subtitle_test.cc (renamed from test/read_subtitle_test.cc)18
-rw-r--r--test/read_smpte_subtitle_test.cc60
-rw-r--r--test/recovery_test.cc2
-rw-r--r--test/rewrite_subs.cc1
-rw-r--r--test/round_trip_test.cc2
-rw-r--r--test/smpte_load_font_test.cc1
-rw-r--r--test/smpte_subtitle_test.cc33
-rw-r--r--test/subs_in_out.cc22
-rw-r--r--test/util_test.cc3
-rw-r--r--test/write_subtitle_test.cc4
-rw-r--r--test/wscript4
22 files changed, 121 insertions, 61 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc
index dc08a193..374dbc13 100644
--- a/test/certificates_test.cc
+++ b/test/certificates_test.cc
@@ -26,6 +26,7 @@ using std::list;
using std::string;
using boost::shared_ptr;
+/** Check that loading certificates from files via strings works */
BOOST_AUTO_TEST_CASE (certificates)
{
dcp::CertificateChain c;
diff --git a/test/colour_conversion_test.cc b/test/colour_conversion_test.cc
index 2eb5edf5..7ff93468 100644
--- a/test/colour_conversion_test.cc
+++ b/test/colour_conversion_test.cc
@@ -54,6 +54,7 @@ check_modified_gamma (shared_ptr<const TransferFunction> tf, int bit_depth, bool
}
}
+/** Check that the gamma correction LUTs are right for sRGB */
BOOST_AUTO_TEST_CASE (colour_conversion_test1)
{
ColourConversion cc = ColourConversion::srgb_to_xyz ();
@@ -67,6 +68,7 @@ BOOST_AUTO_TEST_CASE (colour_conversion_test1)
check_gamma (cc.out(), 16, true, 1 / 2.6);
}
+/** Check that the gamma correction LUTs are right for REC709 */
BOOST_AUTO_TEST_CASE (colour_conversion_test2)
{
ColourConversion cc = ColourConversion::rec709_to_xyz ();
diff --git a/test/colour_test.cc b/test/colour_test.cc
index f2be8ead..cebe95ab 100644
--- a/test/colour_test.cc
+++ b/test/colour_test.cc
@@ -23,7 +23,7 @@
using std::stringstream;
-/* Check that dcp::Colour works */
+/** Check that dcp::Colour works */
BOOST_AUTO_TEST_CASE (colour)
{
dcp::Colour z;
diff --git a/test/cpl_sar_test.cc b/test/cpl_sar_test.cc
index 691439db..cafa589f 100644
--- a/test/cpl_sar_test.cc
+++ b/test/cpl_sar_test.cc
@@ -25,9 +25,9 @@
using boost::shared_ptr;
-/* Test for a reported bug where <ScreenAspectRatio> in Interop files uses
- excessive decimal places and (sometimes) the wrong decimal point character.
-*/
+/** Test for a reported bug where <ScreenAspectRatio> in Interop files uses
+ * excessive decimal places and (sometimes) the wrong decimal point character.
+ */
BOOST_AUTO_TEST_CASE (cpl_sar)
{
shared_ptr<dcp::ReelMonoPictureAsset> pa (
diff --git a/test/dcp_test.cc b/test/dcp_test.cc
index c4950704..0338e1f8 100644
--- a/test/dcp_test.cc
+++ b/test/dcp_test.cc
@@ -101,8 +101,6 @@ BOOST_AUTO_TEST_CASE (dcp_test1)
));
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_meta);
@@ -175,8 +173,6 @@ BOOST_AUTO_TEST_CASE (dcp_test2)
));
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_meta);
diff --git a/test/encryption_test.cc b/test/encryption_test.cc
index 299e5f9b..7786292d 100644
--- a/test/encryption_test.cc
+++ b/test/encryption_test.cc
@@ -41,9 +41,9 @@
using boost::shared_ptr;
-/* Load a certificate chain from build/test/data/ *.pem and then build
- an encrypted DCP and a KDM using it.
-*/
+/** Load a certificate chain from build/test/data/ *.pem and then build
+ * an encrypted DCP and a KDM using it.
+ */
BOOST_AUTO_TEST_CASE (encryption_test)
{
boost::filesystem::remove_all ("build/test/signer");
@@ -124,8 +124,6 @@ BOOST_AUTO_TEST_CASE (encryption_test)
cpl->set_metadata (xml_metadata);
d.add (cpl);
- d.add (mp);
- d.add (ms);
d.write_xml (dcp::SMPTE, xml_metadata, signer);
diff --git a/test/exception_test.cc b/test/exception_test.cc
index 740154dd..dd9608ee 100644
--- a/test/exception_test.cc
+++ b/test/exception_test.cc
@@ -22,6 +22,7 @@
using std::string;
+/** Test exception classes */
BOOST_AUTO_TEST_CASE (exception_test)
{
BOOST_CHECK_EQUAL (string (dcp::FileError ("foo", "bar", 42).what()), "foo (bar) (error 42)");
diff --git a/test/fraction_test.cc b/test/fraction_test.cc
index 445805d1..efdba664 100644
--- a/test/fraction_test.cc
+++ b/test/fraction_test.cc
@@ -21,6 +21,7 @@
#include "exceptions.h"
#include <boost/test/unit_test.hpp>
+/** Test dcp::Fraction */
BOOST_AUTO_TEST_CASE (fraction_test)
{
dcp::Fraction f (42, 26);
diff --git a/test/interop_load_font_test.cc b/test/interop_load_font_test.cc
index 9940c5e0..04520080 100644
--- a/test/interop_load_font_test.cc
+++ b/test/interop_load_font_test.cc
@@ -22,6 +22,7 @@
#include <libxml++/libxml++.h>
#include <boost/test/unit_test.hpp>
+/** Test dcp::InteropLoadFont's simple constructor */
BOOST_AUTO_TEST_CASE (interop_load_font_test1)
{
dcp::InteropLoadFontNode lf ("my-great-id", "my-great-uri");
@@ -29,6 +30,7 @@ BOOST_AUTO_TEST_CASE (interop_load_font_test1)
BOOST_CHECK_EQUAL (lf.uri, "my-great-uri");
}
+/** Test dcp::InteropLoadFont's XML constructor */
BOOST_AUTO_TEST_CASE (interop_load_font_test2)
{
xmlpp::Document doc;
diff --git a/test/kdm_test.cc b/test/kdm_test.cc
index c2d40b3b..4051a44a 100644
--- a/test/kdm_test.cc
+++ b/test/kdm_test.cc
@@ -27,6 +27,7 @@ using std::list;
using std::stringstream;
using boost::shared_ptr;
+/** Check reading and decryption of a KDM */
BOOST_AUTO_TEST_CASE (kdm_test)
{
dcp::DecryptedKDM kdm (
@@ -49,7 +50,7 @@ BOOST_AUTO_TEST_CASE (kdm_test)
BOOST_CHECK_EQUAL (keys.back().key().hex(), "5327fb7ec2e807bd57059615bf8a169d");
}
-/* Check that we can read in a KDM and then write it back out again the same */
+/** Check that we can read in a KDM and then write it back out again the same */
BOOST_AUTO_TEST_CASE (kdm_passthrough_test)
{
dcp::EncryptedKDM kdm (
diff --git a/test/read_dcp_test.cc b/test/read_dcp_test.cc
index 6aed62a4..097d0aa9 100644
--- a/test/read_dcp_test.cc
+++ b/test/read_dcp_test.cc
@@ -24,7 +24,7 @@
using std::list;
using boost::shared_ptr;
-/* Read DCP that is in git and make sure that basic stuff is read in correctly */
+/** Read DCP that is in git and make sure that basic stuff is read in correctly */
BOOST_AUTO_TEST_CASE (read_dcp)
{
dcp::DCP d ("test/ref/DCP/dcp_test1");
diff --git a/test/read_subtitle_test.cc b/test/read_interop_subtitle_test.cc
index c49ddfdf..b268d629 100644
--- a/test/read_subtitle_test.cc
+++ b/test/read_interop_subtitle_test.cc
@@ -18,20 +18,32 @@
*/
#include "interop_subtitle_asset.h"
+#include "interop_load_font_node.h"
#include "subtitle_string.h"
#include <boost/test/unit_test.hpp>
using std::list;
using std::string;
using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
-/* Load some subtitle content from XML and check that it is read correctly */
-BOOST_AUTO_TEST_CASE (read_subtitle_test1)
+/** Load some subtitle content from Interop XML and check that it is read correctly */
+BOOST_AUTO_TEST_CASE (read_interop_subtitle_test1)
{
dcp::InteropSubtitleAsset subs ("test/data/subs1.xml");
+ BOOST_CHECK_EQUAL (subs.id(), "cab5c268-222b-41d2-88ae-6d6999441b17");
+ BOOST_CHECK_EQUAL (subs.movie_title(), "Movie Title");
+ BOOST_CHECK_EQUAL (subs.reel_number(), "1");
BOOST_CHECK_EQUAL (subs.language(), "French");
+ list<shared_ptr<dcp::LoadFontNode> > lfn = subs.load_font_nodes ();
+ BOOST_REQUIRE_EQUAL (lfn.size(), 1);
+ shared_ptr<dcp::InteropLoadFontNode> interop_lfn = dynamic_pointer_cast<dcp::InteropLoadFontNode> (lfn.front ());
+ BOOST_REQUIRE (interop_lfn);
+ BOOST_CHECK_EQUAL (interop_lfn->id, "theFontId");
+ BOOST_CHECK_EQUAL (interop_lfn->uri, "arial.ttf");
+
list<dcp::SubtitleString> s = subs.subtitles_during (dcp::Time (0, 0, 6, 1, 250), dcp::Time (0, 0, 6, 2, 250));
BOOST_REQUIRE_EQUAL (s.size(), 1);
BOOST_CHECK_EQUAL (s.front(), dcp::SubtitleString (
@@ -136,7 +148,7 @@ BOOST_AUTO_TEST_CASE (read_subtitle_test1)
}
/** And similarly for another one */
-BOOST_AUTO_TEST_CASE (read_subtitle_test2)
+BOOST_AUTO_TEST_CASE (read_interop_subtitle_test2)
{
dcp::InteropSubtitleAsset subs ("test/data/subs2.xml");
diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc
new file mode 100644
index 00000000..81749a15
--- /dev/null
+++ b/test/read_smpte_subtitle_test.cc
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "smpte_subtitle_asset.h"
+#include "test.h"
+#include "local_time.h"
+#include "smpte_load_font_node.h"
+#include <boost/test/unit_test.hpp>
+
+using std::list;
+using boost::shared_ptr;
+using boost::dynamic_pointer_cast;
+
+/** Check reading of a SMPTE subtitle file */
+BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test)
+{
+ dcp::SMPTESubtitleAsset sc (private_test / "8dfafe11-2bd1-4206-818b-afc109cfe7f6_reel1.xml", false);
+
+ BOOST_CHECK_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6");
+ BOOST_CHECK_EQUAL (sc.content_title_text(), "Violet");
+ BOOST_REQUIRE (sc.annotation_text());
+ BOOST_CHECK_EQUAL (sc.annotation_text().get(), "Violet");
+ BOOST_CHECK_EQUAL (sc.issue_date(), dcp::LocalTime ("2014-12-23T22:30:07.000-00:00"));
+ BOOST_REQUIRE (sc.reel_number());
+ BOOST_CHECK_EQUAL (sc.reel_number().get(), 1);
+ BOOST_REQUIRE (sc.language ());
+ BOOST_CHECK_EQUAL (sc.language().get (), "Dutch");
+ BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (24, 1));
+ BOOST_CHECK_EQUAL (sc.time_code_rate(), 24);
+ BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 23, 24));
+ list<shared_ptr<dcp::LoadFontNode> > lfn = sc.load_font_nodes ();
+ BOOST_REQUIRE_EQUAL (lfn.size(), 1);
+ shared_ptr<dcp::SMPTELoadFontNode> smpte_lfn = dynamic_pointer_cast<dcp::SMPTELoadFontNode> (lfn.front ());
+ BOOST_REQUIRE (smpte_lfn);
+ BOOST_CHECK_EQUAL (smpte_lfn->id, "theFontId");
+ BOOST_CHECK_EQUAL (smpte_lfn->urn, "3dec6dc0-39d0-498d-97d0-928d2eb78391");
+ BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 159);
+ BOOST_CHECK_EQUAL (sc.subtitles().front().text(), "Jonas ?");
+ BOOST_CHECK_EQUAL (sc.subtitles().front().in(), dcp::Time (0, 7, 6, 20, 24));
+ BOOST_CHECK_EQUAL (sc.subtitles().front().out(), dcp::Time (0, 7, 7, 20, 24));
+ BOOST_CHECK_EQUAL (sc.subtitles().back().text(), "Come on.");
+ BOOST_CHECK_EQUAL (sc.subtitles().back().in(), dcp::Time (1, 13, 37, 11, 24));
+ BOOST_CHECK_EQUAL (sc.subtitles().back().out(), dcp::Time (1, 13, 38, 11, 24));
+}
diff --git a/test/recovery_test.cc b/test/recovery_test.cc
index 257c512d..754a49e2 100644
--- a/test/recovery_test.cc
+++ b/test/recovery_test.cc
@@ -26,7 +26,7 @@
using std::string;
using boost::shared_ptr;
-/* Check that recovery from a partially-written MXF works */
+/** Check that recovery from a partially-written MXF works */
BOOST_AUTO_TEST_CASE (recovery)
{
Kumu::libdcp_test = true;
diff --git a/test/rewrite_subs.cc b/test/rewrite_subs.cc
index 5bfe126f..6aa259a9 100644
--- a/test/rewrite_subs.cc
+++ b/test/rewrite_subs.cc
@@ -32,6 +32,7 @@ using std::string;
using boost::shared_ptr;
using namespace dcp;
+/** Load a DCP then re-write its subtitle XML or MXF in-place */
int
main (int argc, char* argv[])
{
diff --git a/test/round_trip_test.cc b/test/round_trip_test.cc
index a719ff45..39db697b 100644
--- a/test/round_trip_test.cc
+++ b/test/round_trip_test.cc
@@ -43,7 +43,7 @@ using std::list;
using boost::shared_ptr;
using boost::scoped_array;
-/* Build an encrypted picture asset and a KDM for it and check that the KDM can be decrypted */
+/** Build an encrypted picture asset and a KDM for it and check that the KDM can be decrypted */
BOOST_AUTO_TEST_CASE (round_trip_test)
{
shared_ptr<dcp::Signer> signer (new dcp::Signer ("openssl"));
diff --git a/test/smpte_load_font_test.cc b/test/smpte_load_font_test.cc
index 77020b98..da52ed97 100644
--- a/test/smpte_load_font_test.cc
+++ b/test/smpte_load_font_test.cc
@@ -22,6 +22,7 @@
#include <libxml++/libxml++.h>
#include <boost/test/unit_test.hpp>
+/** Test dcp::SMPTELoadFontNode */
BOOST_AUTO_TEST_CASE (smpte_load_font_test1)
{
xmlpp::Document doc;
diff --git a/test/smpte_subtitle_test.cc b/test/smpte_subtitle_test.cc
deleted file mode 100644
index 2b68de3d..00000000
--- a/test/smpte_subtitle_test.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "smpte_subtitle_asset.h"
-#include "test.h"
-#include <boost/test/unit_test.hpp>
-
-/** Load a SMPTE XML subtitle file */
-BOOST_AUTO_TEST_CASE (smpte_subtitle_test)
-{
- dcp::SMPTESubtitleAsset sc (private_test / "8dfafe11-2bd1-4206-818b-afc109cfe7f6_reel1.xml", false);
-
- BOOST_REQUIRE_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6");
- BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 159);
- BOOST_REQUIRE_EQUAL (sc.subtitles().front().text(), "Jonas ?");
- BOOST_REQUIRE_EQUAL (sc.subtitles().back().text(), "Come on.");
-}
diff --git a/test/subs_in_out.cc b/test/subs_in_out.cc
index 2a662262..fce0bfec 100644
--- a/test/subs_in_out.cc
+++ b/test/subs_in_out.cc
@@ -18,18 +18,30 @@
*/
#include "interop_subtitle_asset.h"
+#include "smpte_subtitle_asset.h"
#include <iostream>
using namespace std;
-int main (int argc, char* argv[])
+int
+main (int argc, char* argv[])
{
- if (argc < 2) {
+ if (argc != 2) {
cerr << "Syntax: " << argv[0] << " <subtitle file>\n";
exit (EXIT_FAILURE);
}
-
- dcp::InteropSubtitleAsset s (argv[1]);
- cout << s.xml_as_string ();
+
+ try {
+ dcp::InteropSubtitleAsset sc (argv[1]);
+ cout << sc.xml_as_string ();
+ } catch (exception& e) {
+ cerr << "Could not load as interop: " << e.what() << "\n";
+ try {
+ dcp::SMPTESubtitleAsset sc (argv[1]);
+ cout << sc.xml_as_string().raw ();
+ } catch (exception& e) {
+ cerr << "Could not load as SMPTE (" << e.what() << ")\n";
+ }
+ }
return 0;
}
diff --git a/test/util_test.cc b/test/util_test.cc
index 34dc0c18..d7c41a6a 100644
--- a/test/util_test.cc
+++ b/test/util_test.cc
@@ -24,6 +24,7 @@
using std::ifstream;
using std::string;
+/** Test dcp::base64_decode */
BOOST_AUTO_TEST_CASE (base64_decode_test)
{
int const N = 256;
@@ -55,6 +56,7 @@ BOOST_AUTO_TEST_CASE (base64_decode_test)
}
}
+/** Test dcp::content_kind_from_string */
BOOST_AUTO_TEST_CASE (content_kind_test)
{
BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("feature"), dcp::FEATURE);
@@ -71,6 +73,7 @@ BOOST_AUTO_TEST_CASE (content_kind_test)
BOOST_CHECK_EQUAL (dcp::content_kind_from_string ("advertisement"), dcp::ADVERTISEMENT);
}
+/** Test dcp::relative_to_root */
BOOST_AUTO_TEST_CASE (relative_to_root_test)
{
{
diff --git a/test/write_subtitle_test.cc b/test/write_subtitle_test.cc
index 958fc981..577eadec 100644
--- a/test/write_subtitle_test.cc
+++ b/test/write_subtitle_test.cc
@@ -29,8 +29,10 @@ using boost::shared_ptr;
/* Write some subtitle content as Interop XML and check that it is right */
BOOST_AUTO_TEST_CASE (write_subtitle_test)
{
- dcp::InteropSubtitleAsset c ("Test", "EN");
+ dcp::InteropSubtitleAsset c;
c.set_reel_number ("1");
+ c.set_language ("EN");
+ c.set_movie_title ("Test");
c.add (
dcp::SubtitleString (
diff --git a/test/wscript b/test/wscript
index 30015939..f640f6fc 100644
--- a/test/wscript
+++ b/test/wscript
@@ -40,12 +40,12 @@ def build(bld):
local_time_test.cc
kdm_test.cc
read_dcp_test.cc
- read_subtitle_test.cc
+ read_interop_subtitle_test.cc
+ read_smpte_subtitle_test.cc
recovery_test.cc
rgb_xyz_test.cc
round_trip_test.cc
smpte_load_font_test.cc
- smpte_subtitle_test.cc
test.cc
text_test.cc
util_test.cc