# HG changeset patch # User stefano # Date 1276727812 0 # Node ID 34a4ee2300795403593a8630c8b1f0b5fce7fcff # Parent f05ed91901339ec2849cab8bbf6c39e56617df81 Add more tests to eval, help detecting some of the more apparent errors, far from being a complete test system. diff -r f05ed9190133 -r 34a4ee230079 eval.c --- a/eval.c Wed Jun 16 18:27:55 2010 +0000 +++ b/eval.c Wed Jun 16 22:36:52 2010 +0000 @@ -532,6 +532,44 @@ { 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", + "13k + 12f - 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\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);