--- /dev/null
+[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
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 ());
+}