2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <boost/test/unit_test.hpp>
22 #include "stl_text_writer.h"
32 make (string text, bool bold, bool italic, bool underline, int line, sub::FrameTime from, sub::FrameTime to)
37 s.font_size.points = 42;
40 s.underline = underline;
47 /* Test writing of an textual STL file */
48 BOOST_AUTO_TEST_CASE (stl_text_writer_test)
50 list<sub::Subtitle> subs;
51 subs.push_back (make (" This is a subtitle ", false, false, false, 0, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21)));
52 subs.push_back (make (" and that's a line break", false, false, false, 1, sub::FrameTime (0, 0, 41, 9), sub::FrameTime (0, 0, 42, 21)));
53 subs.push_back (make (" This is some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
54 subs.push_back (make ("bold", true, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
55 subs.push_back (make (" and some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
56 subs.push_back (make ("bold italic", true, true, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
57 subs.push_back (make (" and some ", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
58 subs.push_back (make ("underlined", false, false, true, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
59 subs.push_back (make (".", false, false, false, 0, sub::FrameTime (0, 1, 1, 1), sub::FrameTime (0, 1, 2, 10)));
61 ofstream f ("build/test/test.stl");
62 write_stl_text (subs, 24, 72 * 11, f);
65 check_text ("test/ref/test.stl", "build/test/test.stl");