comparison eval.c @ 947:34a4ee230079 libavutil

Add more tests to eval, help detecting some of the more apparent errors, far from being a complete test system.
author stefano
date Wed, 16 Jun 2010 22:36:52 +0000
parents f05ed9190133
children
comparison
equal deleted inserted replaced
946:f05ed9190133 947:34a4ee230079
530 530
531 int main(void) 531 int main(void)
532 { 532 {
533 int i; 533 int i;
534 double d; 534 double d;
535 const char **expr, *exprs[] = {
536 "",
537 "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
538 "80G/80Gi"
539 "1k",
540 "1Gi",
541 "1gi",
542 "1GiFoo",
543 "1k+1k",
544 "1Gi*3foo",
545 "foo",
546 "foo(",
547 "foo()",
548 "foo)",
549 "sin",
550 "sin(",
551 "sin()",
552 "sin)",
553 "sin 10",
554 "sin(1,2,3)",
555 "sin(1 )",
556 "1",
557 "1foo",
558 "bar + PI + E + 100f*2 + foo",
559 "13k + 12f - foo(1, 2)",
560 "1gi",
561 "1Gi",
562 NULL
563 };
564
565 for (expr = exprs; *expr; expr++) {
566 printf("Evaluating '%s'\n", *expr);
567 av_parse_and_eval_expr(&d, *expr,
568 const_names, const_values,
569 NULL, NULL, NULL, NULL, NULL, 0, NULL);
570 printf("'%s' -> %f\n\n", *expr, d);
571 }
572
535 av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", 573 av_parse_and_eval_expr(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
536 const_names, const_values, 574 const_names, const_values,
537 NULL, NULL, NULL, NULL, NULL, 0, NULL); 575 NULL, NULL, NULL, NULL, NULL, 0, NULL);
538 printf("%f == 12.7\n", d); 576 printf("%f == 12.7\n", d);
539 av_parse_and_eval_expr(&d, "80G/80Gi", 577 av_parse_and_eval_expr(&d, "80G/80Gi",