diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-11 14:57:02 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-11 14:57:02 +0000 |
| commit | 7114a99bf210c5d41a13161aea868fe68dd06e84 (patch) | |
| tree | 5dc29fbcc15acd21d9c344d5b9cdb3789009adf9 /test | |
| parent | 8fd43fface7757bd0d7228ff0490a8c8ad074175 (diff) | |
Rudimentary SSA parser.
Diffstat (limited to 'test')
| -rw-r--r-- | test/ssa_reader_test.cc | 71 | ||||
| -rw-r--r-- | test/wscript | 1 |
2 files changed, 72 insertions, 0 deletions
diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc new file mode 100644 index 0000000..c7594d7 --- /dev/null +++ b/test/ssa_reader_test.cc @@ -0,0 +1,71 @@ +/* + Copyright (C) 2016 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 "test.h" +#include "ssa_reader.h" +#include "collect.h" +#include "subtitle.h" +#include <boost/test/unit_test.hpp> +#include <boost/filesystem.hpp> +#include <cstdio> + +using std::list; + +BOOST_AUTO_TEST_CASE (ssa_reader_test) +{ + boost::filesystem::path p = private_test / "example.ssa"; + FILE* f = fopen (p.string().c_str(), "r"); + sub::SSAReader reader (f); + fclose (f); + list<sub::Subtitle> subs = sub::collect<std::list<sub::Subtitle> > (reader.subtitles ()); + + list<sub::Subtitle>::iterator i = subs.begin (); + + BOOST_REQUIRE (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 40, 650)); + BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 41, 790)); + list<sub::Line>::iterator j = i->lines.begin(); + BOOST_REQUIRE (j != i->lines.end ()); + BOOST_REQUIRE_EQUAL (j->blocks.size(), 1); + sub::Block b = j->blocks.front (); + BOOST_CHECK_EQUAL (b.text, "Et les enregistrements de ses ondes delta ?"); + BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain"); + BOOST_CHECK_EQUAL (b.font_size.points().get(), 56); + BOOST_CHECK_EQUAL (b.bold, false); + BOOST_CHECK_EQUAL (b.italic, false); + BOOST_CHECK_EQUAL (b.underline, false); + ++i; + + BOOST_REQUIRE (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from, sub::Time::from_hms (0, 2, 42, 420)); + BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 2, 44, 150)); + j = i->lines.begin(); + BOOST_REQUIRE (j != i->lines.end ()); + BOOST_REQUIRE_EQUAL (j->blocks.size(), 1); + b = j->blocks.front (); + BOOST_CHECK_EQUAL (b.text, "Toujours rien."); + BOOST_CHECK_EQUAL (b.font.get(), "Wolf_Rain"); + BOOST_CHECK_EQUAL (b.font_size.points().get(), 56); + BOOST_CHECK_EQUAL (b.bold, false); + BOOST_CHECK_EQUAL (b.italic, false); + BOOST_CHECK_EQUAL (b.underline, false); + ++i; + + BOOST_CHECK (i == subs.end()); +} diff --git a/test/wscript b/test/wscript index 94965ec..b7d91cb 100644 --- a/test/wscript +++ b/test/wscript @@ -23,6 +23,7 @@ def build(bld): dcp_reader_test.cc dcp_to_stl_binary_test.cc iso6937_test.cc + ssa_reader_test.cc stl_binary_reader_test.cc stl_binary_writer_test.cc stl_text_reader_test.cc |
