Commit a619787a authored by Marton Balint's avatar Marton Balint

avutil/tests/opt: add av_opt_get/av_opt_set tests

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 672b925e
...@@ -171,6 +171,47 @@ int main(void) ...@@ -171,6 +171,47 @@ int main(void)
av_opt_free(&test_ctx); av_opt_free(&test_ctx);
} }
printf("\nTesting av_opt_get/av_opt_set()\n");
{
TestContext test_ctx = { 0 };
TestContext test2_ctx = { 0 };
const AVOption *o = NULL;
test_ctx.class = &test_class;
test2_ctx.class = &test_class;
av_log_set_level(AV_LOG_QUIET);
av_opt_set_defaults(&test_ctx);
while (o = av_opt_next(&test_ctx, o)) {
char *value1 = NULL;
char *value2 = NULL;
int ret1 = AVERROR_BUG;
int ret2 = AVERROR_BUG;
int ret3 = AVERROR_BUG;
if (o->type == AV_OPT_TYPE_CONST)
continue;
ret1 = av_opt_get(&test_ctx, o->name, 0, (uint8_t **)&value1);
if (ret1 >= 0) {
ret2 = av_opt_set(&test2_ctx, o->name, value1, 0);
if (ret2 >= 0)
ret3 = av_opt_get(&test2_ctx, o->name, 0, (uint8_t **)&value2);
}
printf("name: %-11s get: %-16s set: %-16s get: %-16s %s\n", o->name,
ret1 >= 0 ? value1 : av_err2str(ret1),
ret2 >= 0 ? "OK" : av_err2str(ret2),
ret3 >= 0 ? value2 : av_err2str(ret3),
ret1 >= 0 && ret2 >= 0 && ret3 >= 0 && !strcmp(value1, value2) ? "OK" : "Mismatch");
av_free(value1);
av_free(value2);
}
av_opt_free(&test_ctx);
av_opt_free(&test2_ctx);
}
printf("\nTest av_opt_serialize()\n"); printf("\nTest av_opt_serialize()\n");
{ {
TestContext test_ctx = { 0 }; TestContext test_ctx = { 0 };
......
...@@ -102,6 +102,32 @@ name: bool3 default:1 error: ...@@ -102,6 +102,32 @@ name: bool3 default:1 error:
name: dict1 default:1 error: name: dict1 default:1 error:
name: dict2 default:1 error: name: dict2 default:1 error:
Testing av_opt_get/av_opt_set()
name: num get: 0 set: OK get: 0 OK
name: toggle get: 1 set: OK get: 1 OK
name: rational get: 1/1 set: OK get: 1/1 OK
name: string get: default set: OK get: default OK
name: escape get: \=, set: OK get: \=, OK
name: flags get: 0x00000001 set: OK get: 0x00000001 OK
name: size get: 200x300 set: OK get: 200x300 OK
name: pix_fmt get: 0bgr set: OK get: 0bgr OK
name: sample_fmt get: s16 set: OK get: s16 OK
name: video_rate get: 25/1 set: OK get: 25/1 OK
name: duration get: 0.001 set: OK get: 0.001 OK
name: color get: 0xffc0cbff set: OK get: 0xffc0cbff OK
name: cl get: 0x137 set: OK get: 0x137 OK
name: bin get: 62696E00 set: OK get: 62696E00 OK
name: bin1 get: set: OK get: OK
name: bin2 get: set: OK get: OK
name: num64 get: 1 set: OK get: 1 OK
name: flt get: 0.333333 set: OK get: 0.333333 OK
name: dbl get: 0.333333 set: OK get: 0.333333 OK
name: bool1 get: auto set: OK get: auto OK
name: bool2 get: true set: OK get: true OK
name: bool3 get: false set: OK get: false OK
name: dict1 get: set: OK get: OK
name: dict2 get: happy=\:-) set: OK get: happy=\:-) OK
Test av_opt_serialize() Test av_opt_serialize()
num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=0x137,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-) num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0.001,color=0xffc0cbff,cl=0x137,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333,bool1=auto,bool2=true,bool3=false,dict1=,dict2=happy\=\\:-)
Setting entry with key 'num' to value '0' Setting entry with key 'num' to value '0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment