summaryrefslogtreecommitdiff
path: root/libavcore/parseutils.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-04 13:41:06 +0000
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2010-10-04 13:41:06 +0000
commit00e962a27576cb8169a392c81a9a4252a5791abc (patch)
tree7ab6d77dcee8b19ae75431ee05941f1d0eb0e333 /libavcore/parseutils.c
parentbc12b3b11bc814f6e3f788d38de29f743d31f644 (diff)
Add a test for av_parse_video_rate().
Originally committed as revision 25334 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcore/parseutils.c')
-rw-r--r--libavcore/parseutils.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libavcore/parseutils.c b/libavcore/parseutils.c
index f78949807d..207f6d53eb 100644
--- a/libavcore/parseutils.c
+++ b/libavcore/parseutils.c
@@ -136,3 +136,54 @@ int av_parse_video_rate(AVRational *rate, const char *arg)
return AVERROR(EINVAL);
return 0;
}
+
+#ifdef TEST
+
+#undef printf
+
+int main(void)
+{
+ printf("Testing av_parse_video_rate()\n");
+ {
+ int i;
+ const char *rates[] = {
+ "-inf",
+ "inf",
+ "nan",
+ "123/0",
+ "-123 / 0",
+ "",
+ "/",
+ " 123 / 321",
+ "foo/foo",
+ "foo/1",
+ "1/foo",
+ "0/0",
+ "/0",
+ "1/",
+ "1",
+ "0",
+ "-123/123",
+ "-foo",
+ "123.23",
+ ".23",
+ "-.23",
+ "-0.234",
+ "-0.0000001",
+ " 21332.2324 ",
+ " -21332.2324 ",
+ };
+
+ for (i = 0; i < FF_ARRAY_ELEMS(rates); i++) {
+ int ret;
+ AVRational q = (AVRational){0, 0};
+ ret = av_parse_video_rate(&q, rates[i]),
+ printf("'%s' -> %d/%d ret:%d\n",
+ rates[i], q.num, q.den, ret);
+ }
+ }
+
+ return 0;
+}
+
+#endif /* TEST */