2 Copyright (C) 2016 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.
21 #include "ssa_reader.h"
24 #include <boost/test/unit_test.hpp>
25 #include <boost/filesystem.hpp>
30 BOOST_AUTO_TEST_CASE (ssa_reader_test)
32 boost::filesystem::path p = private_test / "example.ssa";
33 FILE* f = fopen (p.string().c_str(), "r");
34 sub::SSAReader reader (f);
36 list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ());
38 list<sub::Subtitle>::iterator i = subs.begin ();
40 BOOST_REQUIRE (i != subs.end ());
41 BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 40, 650));
42 BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 41, 790));
43 list<sub::Line>::iterator j = i->lines.begin();
44 BOOST_REQUIRE (j != i->lines.end ());
45 BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
46 sub::Block b = j->blocks.front ();
47 BOOST_CHECK_EQUAL (b.text, "Et les enregistrements de ses ondes delta ?");
48 BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain");
49 BOOST_CHECK_EQUAL (b.font_size.points().get(), 56);
50 BOOST_CHECK_EQUAL (b.bold, false);
51 BOOST_CHECK_EQUAL (b.italic, false);
52 BOOST_CHECK_EQUAL (b.underline, false);
55 BOOST_REQUIRE (i != subs.end ());
56 BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 42, 420));
57 BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 44, 150));
59 BOOST_REQUIRE (j != i->lines.end ());
60 BOOST_REQUIRE_EQUAL (j->blocks.size(), 1);
61 b = j->blocks.front ();
62 BOOST_CHECK_EQUAL (b.text, "Toujours rien.");
63 BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain");
64 BOOST_CHECK_EQUAL (b.font_size.points().get(), 56);
65 BOOST_CHECK_EQUAL (b.bold, false);
66 BOOST_CHECK_EQUAL (b.italic, false);
67 BOOST_CHECK_EQUAL (b.underline, false);
70 BOOST_CHECK (i == subs.end());