Add another test stub.
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Jun 2016 21:26:13 +0000 (22:26 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Jun 2016 21:26:13 +0000 (22:26 +0100)
test/data/test.ssa [new file with mode: 0644]
test/ssa_reader_test.cc

diff --git a/test/data/test.ssa b/test/data/test.ssa
new file mode 100644 (file)
index 0000000..578c3d4
--- /dev/null
@@ -0,0 +1,20 @@
+[Script Info]
+Title: libsub test
+ScriptType: v4.00
+WrapStyle: 0
+ScaledBorderAndShadow: yes
+PlayResX: 1920
+PlayResY: 1080
+
+[V4 Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
+Style: Default,Arial,20,16777215,255,0,0,0,0,1,2,2,2,10,10,10,0,1
+
+[Fonts]
+
+[Graphics]
+
+[Events]
+Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: Marked=0,0:00:01.23,0:00:04.55,Default,,0,0,0,,Hello world
+Dialogue: Marked=0,0:00:05.74,0:00:11.00,Default,,0,0,900,,This is vertically moved
index 76043a779910ab07ddfee903e6157c45f9f4128b..7689f4f74afd35a9b87bfeb9a114cff6a02dd4d2 100644 (file)
@@ -118,8 +118,52 @@ test (boost::filesystem::path p)
        fclose (f);
 }
 
-/** Test of reading some typical .srt files */
+/** Test of reading some typical .ssa files */
 BOOST_AUTO_TEST_CASE (ssa_reader_test2)
 {
        test ("DKH_UT_EN20160601def.ssa");
 }
+
+/** Test reading of a file within the libsub tree which exercises the parser */
+BOOST_AUTO_TEST_CASE (ssa_reader_test3)
+{
+       boost::filesystem::path p = "test/data/test.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, 0, 1, 230));
+       BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 4, 550));
+       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, "Hello world");
+       BOOST_CHECK_EQUAL (b.font.get(), "Arial");
+       BOOST_CHECK_EQUAL (b.font_size.points().get(), 20);
+       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, 0, 5, 740));
+       BOOST_CHECK_EQUAL (i->to, sub::Time::from_hms (0, 0, 11, 0));
+       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, "This is vertically moved");
+       BOOST_CHECK_EQUAL (b.font.get(), "Arial");
+       BOOST_CHECK_EQUAL (b.font_size.points().get(), 20);
+       BOOST_CHECK_EQUAL (b.bold, false);
+       BOOST_CHECK_EQUAL (b.italic, false);
+       BOOST_CHECK_EQUAL (b.underline, false);
+       ++i;
+
+       BOOST_REQUIRE (i == subs.end ());
+}