Copy in a test from dcpomatic.
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Oct 2014 10:51:32 +0000 (11:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Oct 2014 10:51:32 +0000 (11:51 +0100)
test/data/test2.srt [new file with mode: 0644]
test/subrip_reader_test.cc

diff --git a/test/data/test2.srt b/test/data/test2.srt
new file mode 100644 (file)
index 0000000..94251d4
--- /dev/null
@@ -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
+<b>We have emboldened this</b>
+
+3
+00:01:54,440 --> 00:01:56,590
+<i>And italicised this.</i>
+
+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.
index fc6a6dbc21942f08d948b43c1d2ae1a1c74ba10e..e0ecc841f3cb1f30003a45122e46a867c741e5f8 100644 (file)
@@ -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<sub::Subtitle> subs = sub::collect (reader.subtitles ());
+
+       list<sub::Subtitle>::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 ());
+}