diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-01-15 11:07:04 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-01-15 11:07:04 +0000 |
| commit | a890bedf688f0066d70dd5e9b07cbd86736cc0b1 (patch) | |
| tree | 683fdd79cfd5e218df23a46fa990b1965f6e5b59 /test/subrip_test.cc | |
| parent | f9608c5299d0a58bc01b33e521d89a80be26ed23 (diff) | |
More testing / SubRip parse fixes.
Diffstat (limited to 'test/subrip_test.cc')
| -rw-r--r-- | test/subrip_test.cc | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/test/subrip_test.cc b/test/subrip_test.cc index f23fc8a0b..a66ee1afd 100644 --- a/test/subrip_test.cc +++ b/test/subrip_test.cc @@ -115,6 +115,57 @@ BOOST_AUTO_TEST_CASE (subrip_content_test) /** Test parsing of full SubRip file content */ BOOST_AUTO_TEST_CASE (subrip_parse_test) { - SubRipContent content (shared_ptr<Film> (), "test/data/subrip.srt"); - content.examine (shared_ptr<Job> ()); + shared_ptr<SubRipContent> content (new SubRipContent (shared_ptr<Film> (), "test/data/subrip.srt")); + content->examine (shared_ptr<Job> ()); + BOOST_CHECK_EQUAL (content->full_length(), ((3 * 60) + 56.471) * TIME_HZ); + + SubRip s (content); + + list<SubRipSubtitle>::const_iterator i = s._subtitles.begin(); + + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((1 * 60) + 49.200) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((1 * 60) + 52.351) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "This is a subtitle, and it goes over two lines."); + + ++i; + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((1 * 60) + 52.440) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((1 * 60) + 54.351) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "We have emboldened this"); + BOOST_CHECK_EQUAL (i->pieces.front().bold, true); + + ++i; + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((1 * 60) + 54.440) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((1 * 60) + 56.590) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "And italicised this."); + BOOST_CHECK_EQUAL (i->pieces.front().italic, true); + + ++i; + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((1 * 60) + 56.680) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((1 * 60) + 58.955) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "Shall I compare thee to a summers' day?"); + + ++i; + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((2 * 60) + 0.840) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((2 * 60) + 3.400) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "Is this a dagger I see before me?"); + + ++i; + BOOST_CHECK (i != s._subtitles.end ()); + BOOST_CHECK_EQUAL (i->from, ((3 * 60) + 54.560) * TIME_HZ); + BOOST_CHECK_EQUAL (i->to, ((3 * 60) + 56.471) * TIME_HZ); + BOOST_CHECK_EQUAL (i->pieces.size(), 1); + BOOST_CHECK_EQUAL (i->pieces.front().text, "Hello world."); + + ++i; + BOOST_CHECK (i == s._subtitles.end ()); } |
