Support rgba() colour specifiers in Subrip files; not sure if they are strictly allow...
[libsub.git] / test / ssa_reader_test.cc
index e5638af4226284a48336b58c143a2a567af36d5c..4aa8ff5e28c01fd08009bf9051b2998aad9ee6e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2016-2019 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 #include "ssa_reader.h"
 #include "collect.h"
 #include "subtitle.h"
+#include "exceptions.h"
 #include <boost/test/unit_test.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/foreach.hpp>
@@ -150,6 +151,8 @@ BOOST_AUTO_TEST_CASE (ssa_reader_test2)
 {
        test ("DKH_UT_EN20160601def.ssa");
        test ("dcpsubtest-en.ssa");
+       test ("dcpsubtest-en.ssa");
+       test ("Widdershins_GERMAN_SUBS_grey.ass");
 }
 
 #define SUB_START(f, t) \
@@ -492,3 +495,34 @@ BOOST_AUTO_TEST_CASE (ssa_reader_fs)
        ++i;
        BOOST_REQUIRE (i == r.end ());
 }
+
+/** Test a valid \c */
+BOOST_AUTO_TEST_CASE (ssa_reader_c)
+{
+       sub::RawSubtitle base;
+       list<sub::RawSubtitle> r = sub::SSAReader::parse_line (
+               base,
+               "{\\c&H00FFFF&}Dieser Untertitel ist gelb",
+               1920, 1080
+               );
+
+       list<sub::RawSubtitle>::const_iterator i = r.begin ();
+       BOOST_CHECK_EQUAL (i->text, "Dieser Untertitel ist gelb");
+       BOOST_CHECK (i->colour == sub::Colour::from_rgb_hex("ffff00"));
+       ++i;
+       BOOST_REQUIRE (i == r.end ());
+}
+
+/** Test invalid \c */
+BOOST_AUTO_TEST_CASE (ssa_reader_c_bad)
+{
+       sub::RawSubtitle base;
+       BOOST_CHECK_THROW(
+               sub::SSAReader::parse_line(
+                       base,
+                       "{\\c&H0}Dieser Untertitel ist gelb",
+                       1920, 1080
+                       ),
+               sub::SSAError
+               );
+}