diff options
author | James Almer <jamrial@gmail.com> | 2024-04-13 11:18:30 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2024-04-23 23:54:46 -0300 |
commit | 855d4b52547b2f8fc38b400e5d18cf44e621e163 (patch) | |
tree | 72f755d30a46f2d2c8ede10254b21ed890655176 /libavutil | |
parent | a9df9f95c43992d60c99cbd2f6bd28a104ed5d0b (diff) | |
download | ffmpeg-855d4b52547b2f8fc38b400e5d18cf44e621e163.tar.gz |
avutil/tests/opt: test av_opt_find2()
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/tests/opt.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c index 32301ba842..d43391025a 100644 --- a/libavutil/tests/opt.c +++ b/libavutil/tests/opt.c @@ -409,5 +409,54 @@ 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; + child_ctx.class = &child_class; + test_ctx.child = &child_ctx; + + av_log_set_level(AV_LOG_QUIET); + + // Should succeed. num exists and has opt_flags 1 + opt = av_opt_find2(&test_ctx, "num", NULL, 1, 0, &target); + if (opt && target == &test_ctx) + printf("OK '%s'\n", opt->name); + else + printf("Error 'num'\n"); + + // Should fail. num64 exists but has opt_flags 1, not 2 + opt = av_opt_find(&test_ctx, "num64", NULL, 2, 0); + if (opt) + printf("OK '%s'\n", opt->name); + else + printf("Error 'num64'\n"); + + // Should fail. child_num exists but in a child object we're not searching + opt = av_opt_find(&test_ctx, "child_num", NULL, 0, 0); + if (opt) + printf("OK '%s'\n", opt->name); + else + printf("Error 'child_num'\n"); + + // Should succeed. child_num exists in a child object we're searching + 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 'child_num'\n"); + + // Should fail. foo doesn't exist + opt = av_opt_find(&test_ctx, "foo", NULL, 0, 0); + if (opt) + printf("OK '%s'\n", opt->name); + else + printf("Error 'foo'\n"); + } + return 0; } |