diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-28 00:34:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-28 00:34:24 +0100 |
| commit | ff72bf25f215f5cb58ee165898968380f9dff73f (patch) | |
| tree | 3286a7821577c5f4632be4bc1dabfcf54f8f98a7 /test | |
| parent | fbce80e667db180244c3b1588e235bf9b2c6cb01 (diff) | |
Fix pango markup when rendering subtitles.
Diffstat (limited to 'test')
| -rw-r--r-- | test/render_subtitles_test.cc | 84 | ||||
| -rw-r--r-- | test/wscript | 1 |
2 files changed, 85 insertions, 0 deletions
diff --git a/test/render_subtitles_test.cc b/test/render_subtitles_test.cc new file mode 100644 index 000000000..c56f9dfa1 --- /dev/null +++ b/test/render_subtitles_test.cc @@ -0,0 +1,84 @@ +/* + Copyright (C) 2016 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic 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. + + DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + +#include "lib/render_subtitles.h" +#include <dcp/subtitle_string.h> +#include <boost/test/unit_test.hpp> + +static void +add (std::list<dcp::SubtitleString>& s, std::string text, bool italic, bool bold, bool underline) +{ + s.push_back ( + dcp::SubtitleString ( + boost::optional<std::string> (), + italic, + bold, + underline, + dcp::Colour (255, 255, 255), + 42, + 1, + dcp::Time (), + dcp::Time (), + 1, + dcp::HALIGN_LEFT, + 1, + dcp::VALIGN_TOP, + dcp::DIRECTION_LTR, + text, + dcp::NONE, + dcp::Colour (0, 0, 0), + dcp::Time (), + dcp::Time () + ) + ); +} + +/** Test marked_up() in render_subtitles.cc */ +BOOST_AUTO_TEST_CASE (render_markup_test1) +{ + std::list<dcp::SubtitleString> s; + add (s, "Hello", false, false, false); + BOOST_CHECK_EQUAL (marked_up (s), "Hello"); +} + +/** Test marked_up() in render_subtitles.cc */ +BOOST_AUTO_TEST_CASE (render_markup_test2) +{ + std::list<dcp::SubtitleString> s; + add (s, "Hello", false, true, false); + BOOST_CHECK_EQUAL (marked_up (s), "<b>Hello</b>"); +} + + +/** Test marked_up() in render_subtitles.cc */ +BOOST_AUTO_TEST_CASE (render_markup_test3) +{ + std::list<dcp::SubtitleString> s; + add (s, "Hello", true, true, false); + BOOST_CHECK_EQUAL (marked_up (s), "<i><b>Hello</b></i>"); +} + +/** Test marked_up() in render_subtitles.cc */ +BOOST_AUTO_TEST_CASE (render_markup_test4) +{ + std::list<dcp::SubtitleString> s; + add (s, "Hello", true, true, true); + BOOST_CHECK_EQUAL (marked_up (s), "<i><b><u>Hello</u></b></i>"); +} diff --git a/test/wscript b/test/wscript index 211ead9c2..d336317e5 100644 --- a/test/wscript +++ b/test/wscript @@ -79,6 +79,7 @@ def build(bld): rect_test.cc reels_test.cc required_disk_space_test.cc + render_subtitles_test.cc resampler_test.cc scaling_test.cc seek_zero_test.cc |
