2 Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "lib/render_subtitles.h"
22 #include <dcp/subtitle_string.h>
23 #include <boost/test/unit_test.hpp>
26 add (std::list<SubtitleString>& s, std::string text, bool italic, bool bold, bool underline)
31 boost::optional<std::string> (),
35 dcp::Colour (255, 255, 255),
47 dcp::Colour (0, 0, 0),
55 /** Test marked_up() in render_subtitles.cc */
56 BOOST_AUTO_TEST_CASE (render_markup_test1)
58 std::list<SubtitleString> s;
59 add (s, "Hello", false, false, false);
60 BOOST_CHECK_EQUAL (marked_up (s), "Hello");
63 /** Test marked_up() in render_subtitles.cc */
64 BOOST_AUTO_TEST_CASE (render_markup_test2)
66 std::list<SubtitleString> s;
67 add (s, "Hello", false, true, false);
68 BOOST_CHECK_EQUAL (marked_up (s), "<b>Hello</b>");
72 /** Test marked_up() in render_subtitles.cc */
73 BOOST_AUTO_TEST_CASE (render_markup_test3)
75 std::list<SubtitleString> s;
76 add (s, "Hello", true, true, false);
77 BOOST_CHECK_EQUAL (marked_up (s), "<i><b>Hello</b></i>");
80 /** Test marked_up() in render_subtitles.cc */
81 BOOST_AUTO_TEST_CASE (render_markup_test4)
83 std::list<SubtitleString> s;
84 add (s, "Hello", true, true, true);
85 BOOST_CHECK_EQUAL (marked_up (s), "<i><b><u>Hello</u></b></i>");
88 /** Test marked_up() in render_subtitles.cc */
89 BOOST_AUTO_TEST_CASE (render_markup_test5)
91 std::list<SubtitleString> s;
92 add (s, "Hello", false, true, false);
93 add (s, " world.", false, false, false);
94 BOOST_CHECK_EQUAL (marked_up (s), "<b>Hello</b> world.");
97 /** Test marked_up() in render_subtitles.cc */
98 BOOST_AUTO_TEST_CASE (render_markup_test6)
100 std::list<SubtitleString> s;
101 add (s, "Hello", true, false, false);
102 add (s, " world ", false, false, false);
103 add (s, "we are bold.", false, true, false);
104 BOOST_CHECK_EQUAL (marked_up (s), "<i>Hello</i> world <b>we are bold.</b>");