summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-25 22:13:28 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-25 22:13:28 +0100
commit170aa07b0c45d031b89815a5d07c8eb7e9226bbe (patch)
tree9a62a89bf461b6c55f4a2bb9eab1d2d8d89d1bfe
parent8181d97d7f9ef0d44af748a5bd5666cf575955fe (diff)
Add DCP -> STL test with -private.
-rwxr-xr-xrun/tests2
-rw-r--r--test/dcp_to_stl_test.cc44
-rw-r--r--test/test.cc16
-rw-r--r--test/test.h4
-rw-r--r--test/wscript1
5 files changed, 66 insertions, 1 deletions
diff --git a/run/tests b/run/tests
index 8529f63..d32bc9a 100755
--- a/run/tests
+++ b/run/tests
@@ -1,4 +1,4 @@
#!/bin/bash -e
export LD_LIBRARY_PATH=build/src
-build/test/tests
+build/test/tests ../libsub-test-private
diff --git a/test/dcp_to_stl_test.cc b/test/dcp_to_stl_test.cc
new file mode 100644
index 0000000..95a5842
--- /dev/null
+++ b/test/dcp_to_stl_test.cc
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2014 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 <fstream>
+#include <boost/test/unit_test.hpp>
+#include "test.h"
+#include "dcp_reader.h"
+#include "stl_writer.h"
+
+using std::string;
+using std::ifstream;
+using std::ofstream;
+
+BOOST_AUTO_TEST_CASE (dcp_to_stl_test)
+{
+ if (private_test.empty ()) {
+ return;
+ }
+
+ string const p = private_test + "/fd586c30-6d38-48f2-8241-27359acf184c_sub.xml";
+ ifstream f (p.c_str ());
+ sub::DCPReader r (f);
+ string const q = "build/test/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl";
+ ofstream g (q.c_str ());
+ sub::STLWriter w (r.subtitles (), 72 * 11, 24, g);
+ string const c = private_test + "/fd586c30-6d38-48f2-8241-27359acf184c_sub.stl";
+ check_text (q, c);
+}
diff --git a/test/test.cc b/test/test.cc
index 3556fa5..423906b 100644
--- a/test/test.cc
+++ b/test/test.cc
@@ -27,6 +27,22 @@ using std::string;
using std::ifstream;
using std::getline;
+string private_test;
+
+struct TestConfig
+{
+ TestConfig()
+ {
+ if (boost::unit_test::framework::master_test_suite().argc >= 2) {
+ private_test = boost::unit_test::framework::master_test_suite().argv[1];
+ } else {
+ BOOST_TEST_MESSAGE ("Private data libsub-test-private not found; some tests will not run");
+ }
+ }
+};
+
+BOOST_GLOBAL_FIXTURE (TestConfig);
+
void
check_text (string a, string b)
{
diff --git a/test/test.h b/test/test.h
index a898694..8bc6e3d 100644
--- a/test/test.h
+++ b/test/test.h
@@ -19,4 +19,8 @@
#include <string>
+using std::string;
+
+extern string private_test;
+
void check_text (std::string a, std::string b);
diff --git a/test/wscript b/test/wscript
index 96a7428..765771e 100644
--- a/test/wscript
+++ b/test/wscript
@@ -17,6 +17,7 @@ def build(bld):
obj.use = 'libsub'
obj.source = """
dcp_reader_test.cc
+ dcp_to_stl_test.cc
stl_reader_test.cc
stl_writer_test.cc
time_test.cc