diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-06 22:26:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-06 22:26:13 +0100 |
| commit | afbe46ea4a0221d22c691b5f60a57c43d19a32cd (patch) | |
| tree | 582f0d3dadf2bca2f0c8de5ee4e4295c800e652d | |
| parent | a06e701131b813bc42ae81b9c5e8c7dbbfea7eb9 (diff) | |
Add another test stub.
| -rw-r--r-- | test/data/test.ssa | 20 | ||||
| -rw-r--r-- | test/ssa_reader_test.cc | 46 |
2 files changed, 65 insertions, 1 deletions
diff --git a/test/data/test.ssa b/test/data/test.ssa new file mode 100644 index 0000000..578c3d4 --- /dev/null +++ b/test/data/test.ssa @@ -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 diff --git a/test/ssa_reader_test.cc b/test/ssa_reader_test.cc index 76043a7..7689f4f 100644 --- a/test/ssa_reader_test.cc +++ b/test/ssa_reader_test.cc @@ -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 ()); +} |
