Commit ada5cdee authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

tests: full coverage for var_InheritURational()

parent 8af0d6b5
......@@ -98,6 +98,74 @@ static void test_floats( libvlc_int_t *p_libvlc )
var_Destroy( p_libvlc, psz_var_name[i] );
}
static void test_fracts( libvlc_int_t *p_libvlc )
{
const char *name = psz_var_name[0];
unsigned num, den;
var_Create( p_libvlc, name, VLC_VAR_STRING );
assert( var_InheritURational( p_libvlc, &num, &den, name ) != 0 );
var_SetString( p_libvlc, name, "123garbage" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) != 0 );
var_SetString( p_libvlc, name, "4/5garbage" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) != 0 );
var_SetString( p_libvlc, name, "6.7garbage" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) != 0 );
var_SetString( p_libvlc, name, "." );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 0 && den == 1 );
var_SetString( p_libvlc, name, "010" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 10 && den == 1 );
var_SetString( p_libvlc, name, "30" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 30 && den == 1 );
var_SetString( p_libvlc, name, "30.0" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 30 && den == 1 );
var_SetString( p_libvlc, name, "030.030" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 3003 && den == 100 );
var_SetString( p_libvlc, name, "60/2" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 30 && den == 1 );
var_SetString( p_libvlc, name, "29.97" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 2997 && den == 100 );
var_SetString( p_libvlc, name, "30000/1001" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 30000 && den == 1001 );
var_SetString( p_libvlc, name, ".125" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 1 && den == 8 );
var_SetString( p_libvlc, name, "12:9" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 4 && den == 3 );
var_SetString( p_libvlc, name, "000000/00000000" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 0 && den == 0 );
var_SetString( p_libvlc, name, "12345/0" );
assert( var_InheritURational( p_libvlc, &num, &den, name ) == 0 );
assert( num == 1 && den == 0 );
var_Destroy( p_libvlc, name );
}
static void test_strings( libvlc_int_t *p_libvlc )
{
for( unsigned i = 0; i < VAR_COUNT; i++ )
......@@ -394,6 +462,9 @@ static void test_variables( libvlc_instance_t *p_vlc )
log( "Testing for floats\n" );
test_floats( p_libvlc );
log( "Testing for rationals\n" );
test_fracts( p_libvlc );
log( "Testing for strings\n" );
test_strings( p_libvlc );
......
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