mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-03 04:23:42 -05:00
[Test,Lexer] Add test for distance parsing, fix bug in em (double)
* Parsed as int, not double.
This commit is contained in:
parent
7291c1f497
commit
38f91e8953
2 changed files with 61 additions and 4 deletions
|
@ -369,8 +369,8 @@ if ( queue == NULL ){
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
<PROPERTIES>{REAL}{EM}{WHITESPACE}{LS_DASH} {
|
<PROPERTIES>{REAL}{EM}{WHITESPACE}{LS_DASH} {
|
||||||
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
yylval->distance.type = PW_PX;
|
yylval->distance.type = PW_EM;
|
||||||
yylval->distance.style = DASH;
|
yylval->distance.style = DASH;
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
|
@ -381,8 +381,8 @@ if ( queue == NULL ){
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
<PROPERTIES>{REAL}{EM}{WHITESPACE}{LS_SOLID} {
|
<PROPERTIES>{REAL}{EM}{WHITESPACE}{LS_SOLID} {
|
||||||
yylval->distance.distance = (double)g_ascii_strtoll(yytext, NULL, 10);
|
yylval->distance.distance = (double)g_ascii_strtod(yytext, NULL);
|
||||||
yylval->distance.type = PW_PX;
|
yylval->distance.type = PW_EM;
|
||||||
yylval->distance.style = SOLID;
|
yylval->distance.style = SOLID;
|
||||||
return T_PIXEL;
|
return T_PIXEL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,63 @@ int main ( int argc, char ** argv )
|
||||||
rofi_theme_free ( rofi_theme );
|
rofi_theme_free ( rofi_theme );
|
||||||
rofi_theme = NULL;
|
rofi_theme = NULL;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
rofi_theme = NULL;
|
||||||
|
error = 0;
|
||||||
|
rofi_theme_parse_string ( "* { sol: 10% solid; dash: 10% dash;}");
|
||||||
|
TASSERT ( error == 0 );
|
||||||
|
Distance d = (Distance){ 1, PW_PX, DASH};
|
||||||
|
Padding pi = (Padding){d,d,d,d};
|
||||||
|
Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
|
||||||
|
TASSERT ( p.left.distance == 10 );
|
||||||
|
TASSERT ( p.left.type == PW_PERCENT );
|
||||||
|
TASSERT ( p.left.style == SOLID );
|
||||||
|
p = rofi_theme_get_padding ( &wid, "dash", pi);
|
||||||
|
TASSERT ( p.left.distance == 10 );
|
||||||
|
TASSERT ( p.left.type == PW_PERCENT );
|
||||||
|
TASSERT ( p.left.style == DASH );
|
||||||
|
TASSERT ( rofi_theme != NULL );
|
||||||
|
rofi_theme_free ( rofi_theme );
|
||||||
|
rofi_theme = NULL;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
rofi_theme = NULL;
|
||||||
|
error = 0;
|
||||||
|
rofi_theme_parse_string ( "* { sol: 10px solid; dash: 14px dash;}");
|
||||||
|
TASSERT ( error == 0 );
|
||||||
|
Distance d = (Distance){ 1, PW_PX, DASH};
|
||||||
|
Padding pi = (Padding){d,d,d,d};
|
||||||
|
Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
|
||||||
|
TASSERT ( p.left.distance == 10 );
|
||||||
|
TASSERT ( p.left.type == PW_PX);
|
||||||
|
TASSERT ( p.left.style == SOLID );
|
||||||
|
p = rofi_theme_get_padding ( &wid, "dash", pi);
|
||||||
|
TASSERT ( p.left.distance == 14 );
|
||||||
|
TASSERT ( p.left.type == PW_PX);
|
||||||
|
TASSERT ( p.left.style == DASH );
|
||||||
|
TASSERT ( rofi_theme != NULL );
|
||||||
|
rofi_theme_free ( rofi_theme );
|
||||||
|
rofi_theme = NULL;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
rofi_theme = NULL;
|
||||||
|
error = 0;
|
||||||
|
rofi_theme_parse_string ( "* { sol: 1.3em solid; dash: 1.5em dash;}");
|
||||||
|
TASSERT ( error == 0 );
|
||||||
|
Distance d = (Distance){ 1, PW_PX, DASH};
|
||||||
|
Padding pi = (Padding){d,d,d,d};
|
||||||
|
Padding p = rofi_theme_get_padding ( &wid, "sol", pi);
|
||||||
|
TASSERT ( p.left.distance == 1.3 );
|
||||||
|
TASSERT ( p.left.type == PW_EM );
|
||||||
|
TASSERT ( p.left.style == SOLID );
|
||||||
|
p = rofi_theme_get_padding ( &wid, "dash", pi);
|
||||||
|
TASSERT ( p.left.distance == 1.5 );
|
||||||
|
TASSERT ( p.left.type == PW_EM );
|
||||||
|
TASSERT ( p.left.style == DASH );
|
||||||
|
TASSERT ( rofi_theme != NULL );
|
||||||
|
rofi_theme_free ( rofi_theme );
|
||||||
|
rofi_theme = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Test newline and link.
|
// Test newline and link.
|
||||||
|
|
Loading…
Reference in a new issue