diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-27 14:50:56 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-27 14:50:56 +0100 |
| commit | f0de0c63504446714ab642f9db872bd31f9c070b (patch) | |
| tree | 45ea6c4219a3a3dbd1dedde65f071ab092c5c290 /test/stl_text_reader_test.cc | |
| parent | 170aa07b0c45d031b89815a5d07c8eb7e9226bbe (diff) | |
Rename STL -> STLText
Diffstat (limited to 'test/stl_text_reader_test.cc')
| -rw-r--r-- | test/stl_text_reader_test.cc | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/test/stl_text_reader_test.cc b/test/stl_text_reader_test.cc new file mode 100644 index 0000000..fa9d448 --- /dev/null +++ b/test/stl_text_reader_test.cc @@ -0,0 +1,145 @@ +/* + Copyright (C) 2014 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 <boost/test/unit_test.hpp> +#include <fstream> +#include "stl_text_reader.h" +#include "subtitle.h" + +using std::list; +using std::ifstream; + +/* Test reading of a textual STL file */ +BOOST_AUTO_TEST_CASE (stl_text_reader_test) +{ + ifstream file ("test/data/test_text.stl"); + sub::STLTextReader reader (file); + list<sub::Subtitle> subs = reader.subtitles (); + + list<sub::Subtitle>::iterator i = subs.begin (); + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, " This is a subtitle "); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 0); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 0, 41, 9)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 0, 42, 21)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, " and that's a line break"); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 1); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 0, 41, 9)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 0, 42, 21)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, " This is some "); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 0); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, "bold"); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, true); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, " and some "); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 0); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, "bold italic"); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, true); + BOOST_CHECK_EQUAL (i->italic, true); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 0); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, " and some "); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->text, "underlined"); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, true); + BOOST_CHECK_EQUAL (i->line, 0); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK_EQUAL (i->text, "."); + BOOST_CHECK_EQUAL (i->font, "Arial"); + BOOST_CHECK_EQUAL (i->font_size.points.get(), 42); + BOOST_CHECK_EQUAL (i->bold, false); + BOOST_CHECK_EQUAL (i->italic, false); + BOOST_CHECK_EQUAL (i->underline, false); + BOOST_CHECK_EQUAL (i->line, 0); + BOOST_CHECK_EQUAL (i->from.frame.get(), sub::FrameTime (0, 1, 1, 1)); + BOOST_CHECK_EQUAL (i->to.frame.get(), sub::FrameTime (0, 1, 2, 10)); + ++i; + + BOOST_CHECK (i == subs.end ()); +} + + |
