@@ -452,5 +452,34 @@ int main(void)
av_opt_free(&test_ctx);
}
+ printf("\nTesting av_opt_find2()\n");
+ {
+ TestContext test_ctx = { 0 };
+ ChildContext child_ctx = { 0 };
+ void *target;
+ const AVOption *opt;
+
+ test_ctx.class = &test_class;
+ test_ctx.child = &child_ctx;
+ child_ctx.class = &child_class;
+ av_opt_set_defaults(&test_ctx);
+ av_opt_set_defaults(&child_ctx);
+
+ av_log_set_level(AV_LOG_QUIET);
+
+ opt = av_opt_find2(&test_ctx, "num", NULL, 0, 0, &target);
+ if (opt && target == &test_ctx)
+ printf("OK '%s'\n", opt->name);
+ else
+ printf("Error '%s'\n", "num");
+
+ opt = av_opt_find2(&test_ctx, "child_num", NULL, 0, AV_OPT_SEARCH_CHILDREN, &target);
+ if (opt && target == &child_ctx)
+ printf("OK '%s'\n", opt->name);
+ else
+ printf("Error '%s'\n", "child_num");
+ av_opt_free(&test_ctx);
+ }
+
return 0;
}
@@ -449,3 +449,7 @@ Setting options string 'a_very_long_option_name_that_will_need_to_be_ellipsized_
Setting 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' to value '42'
Option 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' not found
Error 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
+
+Testing av_opt_find2()
+OK 'num'
+OK 'child_num'
Signed-off-by: James Almer <jamrial@gmail.com> --- libavutil/tests/opt.c | 29 +++++++++++++++++++++++++++++ tests/ref/fate/opt | 4 ++++ 2 files changed, 33 insertions(+)