avutil/tests/opt: add tests for AV_OPT_TYPE_DICT

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2019-12-25 19:35:34 +01:00
parent 5edacc4609
commit 672b925e8a
2 changed files with 18 additions and 2 deletions

View File

@ -55,6 +55,8 @@ typedef struct TestContext {
int bool1;
int bool2;
int bool3;
AVDictionary *dict1;
AVDictionary *dict2;
} TestContext;
#define OFFSET(x) offsetof(TestContext, x)
@ -89,6 +91,8 @@ static const AVOption test_options[]= {
{"bool1", "set boolean value", OFFSET(bool1), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, 1 },
{"bool2", "set boolean value", OFFSET(bool2), AV_OPT_TYPE_BOOL, { .i64 = 1 }, -1, 1, 1 },
{"bool3", "set boolean value", OFFSET(bool3), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 1 },
{"dict1", "set dictionary value", OFFSET(dict1), AV_OPT_TYPE_DICT, { .str = NULL}, 0, 0, 1 },
{"dict2", "set dictionary value", OFFSET(dict2), AV_OPT_TYPE_DICT, { .str = "happy=':-)'"}, 0, 0, 1 },
{ NULL },
};
@ -256,6 +260,7 @@ int main(void)
"dbl=101",
"bool1=true",
"bool2=auto",
"dict1='happy=\\:-):sad=\\:-('",
};
test_ctx.class = &test_class;

View File

@ -43,6 +43,8 @@ TestContext AVOptions:
-bool1 <boolean> E......... set boolean value (default auto)
-bool2 <boolean> E......... set boolean value (default true)
-bool3 <boolean> E......... set boolean value (default false)
-dict1 <dictionary> E......... set dictionary value
-dict2 <dictionary> E......... set dictionary value (default "happy=':-)'")
Testing av_opt_is_set_to_default()
name: num default:1 error:
@ -70,6 +72,8 @@ name: dbl default:0 error:
name: bool1 default:0 error:
name: bool2 default:0 error:
name: bool3 default:1 error:
name: dict1 default:1 error:
name: dict2 default:0 error:
name: num default:1 error:
name: toggle default:1 error:
name: rational default:1 error:
@ -95,9 +99,11 @@ name: dbl default:1 error:
name: bool1 default:1 error:
name: bool2 default:1 error:
name: bool3 default:1 error:
name: dict1 default:1 error:
name: dict2 default:1 error:
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
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 'toggle' to value '1'
Setting entry with key 'rational' to value '1/1'
@ -120,7 +126,9 @@ Setting entry with key 'dbl' to value '0.333333'
Setting entry with key 'bool1' to value 'auto'
Setting entry with key 'bool2' to value 'true'
Setting entry with key 'bool3' to value 'false'
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
Setting entry with key 'dict1' to value ''
Setting entry with key 'dict2' to value '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\=\\:-)
Testing av_set_options_string()
Setting options string ''
@ -341,6 +349,9 @@ OK 'bool1=true'
Setting options string 'bool2=auto'
Setting entry with key 'bool2' to value 'auto'
OK 'bool2=auto'
Setting options string 'dict1='happy=\:-):sad=\:-(''
Setting entry with key 'dict1' to value 'happy=\:-):sad=\:-('
OK 'dict1='happy=\:-):sad=\:-(''
Testing av_opt_set_from_string()
Setting options string ''