Add DCP -> STL test with -private.
authorCarl Hetherington <cth@carlh.net>
Sun, 25 May 2014 21:13:28 +0000 (22:13 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 25 May 2014 21:13:28 +0000 (22:13 +0100)
run/tests
test/dcp_to_stl_test.cc [new file with mode: 0644]
test/test.cc
test/test.h
test/wscript

index 8529f63c09b64b17aa0e133756359d955c452875..d32bc9adf3ec78dbb1101fe00e25b3bd6564f796 100755 (executable)
--- 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 (file)
index 0000000..95a5842
--- /dev/null
@@ -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);
+}
index 3556fa5fa228123c6539f61dcd1783a7041e4680..423906b02cf3305a14072908221483ed40d09395 100644 (file)
@@ -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)
 {
index a8986949f5f67f0a8a07866c4e58fb1bb5c44f27..8bc6e3d7ab68b7f433090a95aa34bef7525eee5f 100644 (file)
@@ -19,4 +19,8 @@
 
 #include <string>
 
+using std::string;
+
+extern string private_test;
+
 void check_text (std::string a, std::string b);
index 96a7428d43bfc8ee5dea2d850974a96dd68b6d74..765771ee5bd87c26d2737feafca60af24854140f 100644 (file)
@@ -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