Add another .srt test; remove checking of .srt subtitle indices as the strict sequenc...
authorCarl Hetherington <cth@carlh.net>
Fri, 3 Oct 2014 18:40:11 +0000 (19:40 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 3 Oct 2014 18:40:11 +0000 (19:40 +0100)
src/lib/subrip.cc
test/subrip_test.cc

index 11ad3302d3659abf107eed8b8fa69d33d8109c69..6c9cef91655c9fe83efce7724c781196ab6aff13 100644 (file)
@@ -49,20 +49,19 @@ SubRip::SubRip (shared_ptr<const SubRipContent> content)
        } state = COUNTER;
 
        char buffer[256];
        } state = COUNTER;
 
        char buffer[256];
-       int next_count = 1;
 
        boost::optional<SubRipSubtitle> current;
        list<string> lines;
 
        boost::optional<SubRipSubtitle> current;
        list<string> lines;
-       
+
        while (!feof (f)) {
                fgets (buffer, sizeof (buffer), f);
                if (feof (f)) {
                        break;
                }
        while (!feof (f)) {
                fgets (buffer, sizeof (buffer), f);
                if (feof (f)) {
                        break;
                }
-               
+
                string line (buffer);
                trim_right_if (line, boost::is_any_of ("\n\r"));
                string line (buffer);
                trim_right_if (line, boost::is_any_of ("\n\r"));
-               
+
                switch (state) {
                case COUNTER:
                {
                switch (state) {
                case COUNTER:
                {
@@ -70,21 +69,9 @@ SubRip::SubRip (shared_ptr<const SubRipContent> content)
                                /* a blank line at the start is ok */
                                break;
                        }
                                /* a blank line at the start is ok */
                                break;
                        }
-                       
-                       int x = 0;
-                       try {
-                               x = lexical_cast<int> (line);
-                       } catch (...) {
 
 
-                       }
-
-                       if (x == next_count) {
-                               state = METADATA;
-                               ++next_count;
-                               current = SubRipSubtitle ();
-                       } else {
-                               throw SubRipError (line, _("a subtitle count"), content->path (0));
-                       }
+                       state = METADATA;
+                       current = SubRipSubtitle ();
                }
                break;
                case METADATA:
                }
                break;
                case METADATA:
index 84ad7f25d4148b87e4ae5471e06263769ef2e3a5..0827005c166050c1be1b212388c5184c59d1ba49 100644 (file)
@@ -202,11 +202,18 @@ BOOST_AUTO_TEST_CASE (subrip_render_test)
        check_file ("build/test/subrip_render_test.png", "test/data/subrip_render_test.png");
 }
 
        check_file ("build/test/subrip_render_test.png", "test/data/subrip_render_test.png");
 }
 
-/** Test of reading a typical .srt */
-BOOST_AUTO_TEST_CASE (subrip_read_test)
+static void
+test (boost::filesystem::path p)
 {
 {
-       shared_ptr<Film> film = new_test_film ("subrip_read_test");
-       boost::filesystem::path p = private_data / "sintel_en.srt";
-       shared_ptr<SubRipContent> s (new SubRipContent (film, p));
+       shared_ptr<Film> film = new_test_film ("subrip_read_test_" + p.string ());
+       boost::filesystem::path t = private_data / p;
+       shared_ptr<SubRipContent> s (new SubRipContent (film, t));
        s->examine (shared_ptr<Job> ());
 }
        s->examine (shared_ptr<Job> ());
 }
+
+/** Test of reading some typical .srt files */
+BOOST_AUTO_TEST_CASE (subrip_read_test)
+{
+       test ("sintel_en.srt");
+       test ("Fight.Club.1999.720p.BRRip.x264-x0r.srt");
+}