[FFmpeg-devel] [PATCH 1/6] Add more tests to eval, help detecting more apparent errors.

Stefano Sabatini stefano.sabatini-lala
Sun Jun 13 00:38:03 CEST 2010


---
 libavutil/eval.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/libavutil/eval.c b/libavutil/eval.c
index 59ebd94..cfe71e1 100644
--- a/libavutil/eval.c
+++ b/libavutil/eval.c
@@ -526,6 +526,44 @@ int main(void)
 {
     int i;
     double d;
+    const char **expr, *exprs[] = {
+        "",
+        "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+        "80G/80Gi"
+        "1k",
+        "1Gi",
+        "1gi",
+        "1GiFoo",
+        "1k+1k",
+        "1Gi*3foo",
+        "foo",
+        "foo(",
+        "foo()",
+        "foo)",
+        "sin",
+        "sin(",
+        "sin()",
+        "sin)",
+        "sin 10",
+        "sin(1,2,3)",
+        "sin(1 )",
+        "1",
+        "1foo",
+        "bar + PI + E + 100f*2 + foo",
+        "foo(1, 2)",
+        "1gi",
+        "1Gi",
+        NULL
+    };
+
+    for (expr = exprs; *expr; expr++) {
+        printf("Evaluating '%s'\n", *expr);
+        av_parse_and_eval_expr(&d, *expr,
+                               const_names, const_values,
+                               NULL, NULL, NULL, NULL, NULL, 0, NULL);
+        printf("'%s' -> %f\n", *expr, d);
+    }
+
     av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
                            const_names, const_values,
                            NULL, NULL, NULL, NULL, NULL, 0, NULL);
-- 
1.7.1




More information about the ffmpeg-devel mailing list