summaryrefslogtreecommitdiff
path: root/libavcodec/tests
diff options
context:
space:
mode:
authorClément Bœsch <u@pkh.me>2017-07-29 20:56:55 +0200
committerClément Bœsch <u@pkh.me>2017-08-01 15:50:00 +0200
commit55949e3e51890de36574d8b5c27889b44108a839 (patch)
tree101df8fc992f0942718341da418278cee7045a48 /libavcodec/tests
parentf0f8da545d80665ae54d51df61e8f6903c85390a (diff)
downloadffmpeg-55949e3e51890de36574d8b5c27889b44108a839.tar.gz
lavc/tests: add htmlsubtitles
Diffstat (limited to 'libavcodec/tests')
-rw-r--r--libavcodec/tests/.gitignore1
-rw-r--r--libavcodec/tests/htmlsubtitles.c49
2 files changed, 50 insertions, 0 deletions
diff --git a/libavcodec/tests/.gitignore b/libavcodec/tests/.gitignore
index f22ac821cb..31947bf9bb 100644
--- a/libavcodec/tests/.gitignore
+++ b/libavcodec/tests/.gitignore
@@ -6,6 +6,7 @@
/fft-fixed
/fft-fixed32
/golomb
+/htmlsubtitles
/iirfilter
/imgconvert
/jpeg2000dwt
diff --git a/libavcodec/tests/htmlsubtitles.c b/libavcodec/tests/htmlsubtitles.c
new file mode 100644
index 0000000000..d0b55a45d3
--- /dev/null
+++ b/libavcodec/tests/htmlsubtitles.c
@@ -0,0 +1,49 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/common.h"
+#include "libavcodec/htmlsubtitles.c"
+
+static const char * const test_cases[] = {
+ /* latin guillemets and other < > garbage */
+ "<<hello>>", // guillemets
+ "<<<b>hello</b>>>", // guillemets + tags
+ "< hello < 2000 > world >", // unlikely tags due to spaces
+ "<h1>TITLE</h1>", // likely unhandled tags
+ "< font color=red >red</font>", // invalid format of valid tag
+ "Foo <foo@bar.com>", // not a tag (not alnum)
+
+ "<b> foo <I> bar </B> bla </i>", // broken nesting
+};
+
+int main(void)
+{
+ int i;
+ AVBPrint dst;
+
+ av_bprint_init(&dst, 0, AV_BPRINT_SIZE_UNLIMITED);
+ for (i = 0; i < FF_ARRAY_ELEMS(test_cases); i++) {
+ int ret = ff_htmlmarkup_to_ass(NULL, &dst, test_cases[i]);
+ if (ret < 0)
+ return ret;
+ printf("%s --> %s\n", test_cases[i], dst.str);
+ av_bprint_clear(&dst);
+ }
+ av_bprint_finalize(&dst, NULL);
+ return 0;
+}