[FFmpeg-devel] [PATCH 2/3] parseutils: add FATE test.
Nicolas George
nicolas.george at normalesup.org
Mon Apr 16 13:33:38 CEST 2012
It requires adding an option to the test program
to avoid random lines.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavutil/parseutils.c | 11 ++++++--
tests/fate/libavutil.mak | 4 +++
tests/ref/fate/parseutils | 61 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+), 3 deletions(-)
create mode 100644 tests/ref/fate/parseutils
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index df737f6..09c56a0 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -679,8 +679,13 @@ int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info
#undef printf
-int main(void)
+int main(int argc, char **argv)
{
+ int deterministic = 0;
+
+ if (argc >= 2 && !strcmp(argv[1], "-fate"))
+ deterministic = 1;
+
printf("Testing av_parse_video_rate()\n");
{
int i;
@@ -728,6 +733,7 @@ int main(void)
const char *color_names[] = {
"bikeshed",
"RaNdOm",
+ "random at 10",
"foo",
"red",
"Red ",
@@ -748,7 +754,6 @@ int main(void)
"ff0000",
"ffXX00",
"red at foo",
- "random at 10",
"0xff0000 at 1.0",
"red@",
"red at 0xfff",
@@ -766,7 +771,7 @@ int main(void)
av_log_set_level(AV_LOG_DEBUG);
- for (i = 0; i < FF_ARRAY_ELEMS(color_names); i++) {
+ for (i = deterministic ? 3 : 0; i < FF_ARRAY_ELEMS(color_names); i++) {
if (av_parse_color(rgba, color_names[i], -1, NULL) >= 0)
printf("%s -> R(%d) G(%d) B(%d) A(%d)\n", color_names[i], rgba[0], rgba[1], rgba[2], rgba[3]);
else
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 37dc99e..a4d4cf5 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -33,6 +33,10 @@ FATE_LIBAVUTIL += fate-md5
fate-md5: libavutil/md5-test$(EXESUF)
fate-md5: CMD = run libavutil/md5-test
+FATE_LIBAVUTIL += fate-parseutils
+fate-parseutils: libavutil/parseutils-test$(EXESUF)
+fate-parseutils: CMD = run libavutil/parseutils-test -fate
+
FATE_LIBAVUTIL += fate-random_seed
fate-random_seed: libavutil/random_seed-test$(EXESUF)
fate-random_seed: CMD = run libavutil/random_seed-test
diff --git a/tests/ref/fate/parseutils b/tests/ref/fate/parseutils
new file mode 100644
index 0000000..d52cb3b
--- /dev/null
+++ b/tests/ref/fate/parseutils
@@ -0,0 +1,61 @@
+Testing av_parse_video_rate()
+'-inf' -> -1/0 ret:-22
+'inf' -> 1/0 ret:-22
+'nan' -> 0/0 ret:-22
+'123/0' -> 1/0 ret:-22
+'-123 / 0' -> -1/0 ret:-22
+'' -> 0/0 ret:-22
+'/' -> 0/0 ret:-22
+' 123 / 321' -> 41/107 ret:0
+'foo/foo' -> 0/0 ret:-22
+'foo/1' -> 0/0 ret:-22
+'1/foo' -> 1/0 ret:-22
+'0/0' -> 0/0 ret:-22
+'/0' -> 0/0 ret:-22
+'1/' -> 1/0 ret:-22
+'1' -> 1/1 ret:0
+'0' -> 0/1 ret:-22
+'-123/123' -> -1/1 ret:-22
+'-foo' -> 0/0 ret:-22
+'123.23' -> 12323/100 ret:0
+'.23' -> 23/100 ret:0
+'-.23' -> -23/100 ret:-22
+'-0.234' -> -117/500 ret:-22
+'-0.0000001' -> 0/1 ret:-22
+' 21332.2324 ' -> 917286/43 ret:0
+' -21332.2324 ' -> -917286/43 ret:-22
+
+Testing av_parse_color()
+foo -> error
+red -> R(255) G(0) B(0) A(255)
+Red -> error
+RED -> R(255) G(0) B(0) A(255)
+Violet -> R(238) G(130) B(238) A(255)
+Yellow -> R(255) G(255) B(0) A(255)
+Red -> R(255) G(0) B(0) A(255)
+0x000000 -> R(0) G(0) B(0) A(255)
+0x0000000 -> error
+0xff000000 -> R(255) G(0) B(0) A(0)
+0x3e34ff -> R(62) G(52) B(255) A(255)
+0x3e34ffaa -> R(62) G(52) B(255) A(170)
+0xffXXee -> error
+0xfoobar -> error
+0xffffeeeeeeee -> error
+#ff0000 -> R(255) G(0) B(0) A(255)
+#ffXX00 -> error
+ff0000 -> R(255) G(0) B(0) A(255)
+ffXX00 -> error
+red at foo -> error
+0xff0000 at 1.0 -> R(255) G(0) B(0) A(255)
+red@ -> error
+red at 0xfff -> error
+red at 0xf -> R(255) G(0) B(0) A(15)
+red at 2 -> error
+red at 0.1 -> R(255) G(0) B(0) A(25)
+red at -1 -> error
+red at 0.5 -> R(255) G(0) B(0) A(127)
+red at 1.0 -> R(255) G(0) B(0) A(255)
+red at 256 -> error
+red at 10foo -> error
+red at -1.0 -> error
+red at -0.0 -> R(255) G(0) B(0) A(0)
--
1.7.2.5
More information about the ffmpeg-devel
mailing list