From ae10bb2a702ab08c497b940d43f0d6e85ae26970 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 6 Oct 2014 11:51:32 +0100 Subject: Copy in a test from dcpomatic. --- test/data/test2.srt | 24 +++++++++++++++++++ test/subrip_reader_test.cc | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 test/data/test2.srt diff --git a/test/data/test2.srt b/test/data/test2.srt new file mode 100644 index 0000000..94251d4 --- /dev/null +++ b/test/data/test2.srt @@ -0,0 +1,24 @@ +1 +00:01:49,200 --> 00:01:52,351 +This is a subtitle, and it goes +over two lines. + +2 +00:01:52,440 --> 00:01:54,351 +We have emboldened this + +3 +00:01:54,440 --> 00:01:56,590 +And italicised this. + +4 +00:01:56,680 --> 00:01:58,955 +Shall I compare thee to a summers' day? + +5 +00:02:00,840 --> 00:02:03,400 +Is this a dagger I see before me? + +6 +00:03:54,560 --> 00:03:56,471 +Hello world. diff --git a/test/subrip_reader_test.cc b/test/subrip_reader_test.cc index fc6a6db..e0ecc84 100644 --- a/test/subrip_reader_test.cc +++ b/test/subrip_reader_test.cc @@ -151,4 +151,61 @@ BOOST_AUTO_TEST_CASE (subrip_reader_test) BOOST_CHECK (k == l.blocks.end ()); } +/* Test reading of another Subrip file */ +BOOST_AUTO_TEST_CASE (subrip_reader_test2) +{ + FILE* f = fopen ("test/data/test2.srt", "r"); + sub::SubripReader reader (f); + fclose (f); + list subs = sub::collect (reader.subtitles ()); + + list::const_iterator i = subs.begin(); + + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 1, 49, 200)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 1, 52, 351)); + BOOST_CHECK_EQUAL (i->lines.size(), 2); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "This is a subtitle, and it goes "); + BOOST_CHECK_EQUAL (i->lines.back().blocks.front().text, "over two lines."); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 1, 52, 440)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 1, 54, 351)); + BOOST_CHECK_EQUAL (i->lines.size(), 1); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "We have emboldened this"); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().bold, true); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 1, 54, 440)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 1, 56, 590)); + BOOST_CHECK_EQUAL (i->lines.size(), 1); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "And italicised this."); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().italic, true); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 1, 56, 680)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 1, 58, 955)); + BOOST_CHECK_EQUAL (i->lines.size(), 1); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "Shall I compare thee to a summers' day?"); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 2, 0, 840)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 2, 3, 400)); + BOOST_CHECK_EQUAL (i->lines.size(), 1); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "Is this a dagger I see before me?"); + + ++i; + BOOST_CHECK (i != subs.end ()); + BOOST_CHECK_EQUAL (i->from.metric().get(), sub::MetricTime (0, 3, 54, 560)); + BOOST_CHECK_EQUAL (i->to.metric().get(), sub::MetricTime (0, 3, 56, 471)); + BOOST_CHECK_EQUAL (i->lines.size(), 1); + BOOST_CHECK_EQUAL (i->lines.front().blocks.front().text, "Hello world."); + + ++i; + BOOST_CHECK (i == subs.end ()); +} -- cgit v1.2.3