summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2018-10-16 21:01:45 +0200
committerDave Davenport <qball@gmpclient.org>2018-10-16 21:01:45 +0200
commite8edc42f9d078f7cde5b71e7780c0d6a1c99e96c (patch)
treefd2785ff85d72ebae546d77e4e4ef364aa9f8d84 /test
parent6830e5d11727043737bacbe59539655058b77224 (diff)
[Helper] Quick and dirty string replacer with optional keys block.
First (quick and dirty) version of a more advanced key replacer where sets of text are only outputted if the contained key matches.
Diffstat (limited to 'test')
-rw-r--r--test/helper-test.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/helper-test.c b/test/helper-test.c
index ddafde63..052af651 100644
--- a/test/helper-test.c
+++ b/test/helper-test.c
@@ -156,4 +156,30 @@ int main ( int argc, char ** argv )
TASSERTL ( rofi_scorer_fuzzy_evaluate ("aap noot mies", 12,"Anm", 3 ), 1073741824);
}
+
+
+ char *a;
+ a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", NULL);
+ printf("%s\n",a);
+ TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -t some title blub -e aap") == 0);
+ g_free(a);
+ a = helper_string_replace_if_exists ( "{terminal} [-t {title} blub ]-e {cmd}", "{cmd}", "aap", NULL);
+ printf("%s\n",a);
+ TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
+ g_free(a);
+ a = helper_string_replace_if_exists ( "{name} [<span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", "{category}", "Desktop app", NULL );
+ printf("%s\n",a);
+ TASSERT ( g_utf8_collate ( a, "Librecad <span weight='light' size='small'><i>(Desktop app)</i></span>") == 0);
+ g_free(a);
+ a = helper_string_replace_if_exists ( "{name}[ <span weight='light' size='small'><i>({category})</i></span>]", "{name}", "Librecad", NULL );
+ TASSERT ( g_utf8_collate ( a, "Librecad") == 0);
+ g_free(a);
+ a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", "some title", NULL);
+ printf("%s\n",a);
+ TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal some title blub -e aap") == 0);
+ g_free(a);
+ a = helper_string_replace_if_exists ( "{terminal} [{title} blub ]-e {cmd}", "{cmd}", "aap", "{title}", NULL, NULL);
+ printf("%s\n",a);
+ TASSERT ( g_utf8_collate ( a, "rofi-sensible-terminal -e aap") == 0);
+ g_free(a);
}