From d163a21b47b7d4ee13f0fdd7eafad14aba8506c1 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 24 Jan 2022 23:47:34 +0100 Subject: [PATCH] Some cleanups --- lexer/theme-lexer.l | 4 ++-- test/theme-parser-test.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index df90cb44..de2eeb67 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -273,8 +273,8 @@ CALC (?i:calc) COMMA , FORWARD_SLASH \/ -LIST_OPEN [\[] -LIST_CLOSE [\]] +LIST_OPEN \[ +LIST_CLOSE \] VAR_START "var" ENV_START "env" diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index e79438a4..aa123e63 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -1147,7 +1147,28 @@ START_TEST(test_properties_cursor_case) { ROFI_CURSOR_TEXT); } END_TEST +START_TEST(test_properties_list) { + widget wid; + wid.name = "blaat"; + wid.state = NULL; + rofi_theme_parse_string( + "#blaat { liste: []; list1: [ one ]; list2: [ one, two ];}"); + GList *list = rofi_theme_get_list_strings(&wid, "liste"); + ck_assert_ptr_null(list); + list = rofi_theme_get_list_strings(&wid, "list1"); + ck_assert_ptr_nonnull(list); + ck_assert_str_eq((char *)list->data, "one"); + g_list_free_full(list, (GDestroyNotify)g_free); + list = rofi_theme_get_list_strings(&wid, "list2"); + ck_assert_ptr_nonnull(list); + ck_assert_int_eq(g_list_length(list), 2); + list = g_list_first(list); + ck_assert_str_eq((char *)list->data, "one"); + ck_assert_str_eq((char *)list->next->data, "two"); + g_list_free_full(list, (GDestroyNotify)g_free); +} +END_TEST START_TEST(test_configuration) { rofi_theme_parse_string("configuration { font: \"blaat€\"; yoffset: 4; }"); ck_assert_int_eq(g_utf8_collate(config.menu_font, "blaat€"), 0); @@ -1433,6 +1454,13 @@ static Suite *theme_parser_suite(void) { tcase_add_test(tc_prop_configuration, test_configuration); suite_add_tcase(s, tc_prop_configuration); } + { + TCase *tc_prop_list = tcase_create("Propertieslist"); + tcase_add_checked_fixture(tc_prop_list, theme_parser_setup, + theme_parser_teardown); + tcase_add_test(tc_prop_list, test_properties_list); + suite_add_tcase(s, tc_prop_list); + } { TCase *tc_prop_parse_file = tcase_create("ParseFile"); tcase_add_checked_fixture(tc_prop_parse_file, theme_parser_setup,