[Lexer] More tests.

Fix return of double.
This commit is contained in:
Dave Davenport 2017-04-26 23:24:14 +02:00
parent 484aa35716
commit ac2390c76d
3 changed files with 44 additions and 3 deletions

View File

@ -344,7 +344,7 @@ int rofi_theme_get_boolean ( const widget *widget, const char *property, int
*
* @returns The string value of this property for this widget.
*/
char *rofi_theme_get_string ( const widget *widget, const char *property, char *def );
const char *rofi_theme_get_string ( const widget *widget, const char *property, char *def );
/**
* @param widget The widget to query

View File

@ -527,7 +527,7 @@ int rofi_theme_get_boolean ( const widget *widget, const char *property, int def
return def;
}
char *rofi_theme_get_string ( const widget *widget, const char *property, char *def )
const char *rofi_theme_get_string ( const widget *widget, const char *property, char *def )
{
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
Property *p = rofi_theme_find_property ( wid, P_STRING, property, FALSE );
@ -542,7 +542,7 @@ double rofi_theme_get_double ( const widget *widget, const char *property, doubl
ThemeWidget *wid = rofi_theme_find_widget ( widget->name, widget->state, FALSE );
Property *p = rofi_theme_find_property ( wid, P_DOUBLE, property, FALSE );
if ( p ) {
return p->value.b;
return p->value.f;
}
g_debug ( "Theme entry: #%s %s property %s unset.", widget->name, widget->state ? widget->state : "", property );
return def;

View File

@ -321,6 +321,13 @@ int main ( int argc, char ** argv )
TASSERT ( th.style == (HL_ITALIC|HL_UNDERLINE));
th = rofi_theme_get_highlight ( &wid, "italicu", th);
TASSERT ( th.style == (HL_ITALIC|HL_UNDERLINE));
rofi_theme_parse_string ( "* { comb: bold #123; }");
th = rofi_theme_get_highlight ( &wid, "comb", th);
TASSERT ( th.style == (HL_BOLD));
TASSERT ( th.color.r == (1/15.0));
TASSERT ( th.color.g == (2/15.0));
TASSERT ( th.color.b == (3/15.0));
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
@ -477,6 +484,40 @@ int main ( int argc, char ** argv )
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
{
error = 0;
rofi_theme_parse_string ( "* { test: 10px 20px;}");
TASSERT ( error == 0 );
Distance d = (Distance){ 1, PW_PX, SOLID};
Padding pi = (Padding){d,d,d,d};
Padding p = rofi_theme_get_padding ( &wid, "test", pi);
TASSERT ( p.left.distance == 20 );
TASSERT ( p.left.type == PW_PX );
TASSERT ( p.right.distance == 20 );
TASSERT ( p.right.type == PW_PX );
TASSERT ( p.top.distance == 10 );
TASSERT ( p.top.type == PW_PX );
TASSERT ( p.bottom.distance == 10 );
TASSERT ( p.bottom.type == PW_PX );
TASSERT ( rofi_theme != NULL );
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
{
rofi_theme = NULL;
error = 0;
rofi_theme_parse_string ( "* { font: \"blaat€\"; test: 123.432; }");
TASSERT ( error == 0 );
const char *str= rofi_theme_get_string ( &wid, "font", NULL );
TASSERT( str != NULL );
TASSERT ( g_utf8_collate ( str, "blaat€" ) == 0 );
TASSERT ( rofi_theme_get_double ( &wid, "test", 0.0) == 123.432 );
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
{
rofi_theme = NULL;
rofi_theme_parse_file ("/dev/null");