Add simple test for notification_replace_format
This commit is contained in:
parent
4e1b97f3cc
commit
d445661031
@ -67,6 +67,7 @@ int notification_close(notification * n, int reason);
|
|||||||
void notification_print(notification * n);
|
void notification_print(notification * n);
|
||||||
char *notification_strip_markup(char *str);
|
char *notification_strip_markup(char *str);
|
||||||
char *notification_quote_markup(char *str);
|
char *notification_quote_markup(char *str);
|
||||||
|
char *notification_replace_format(const char *needle, const char *replacement, char *haystack, enum markup_mode markup);
|
||||||
void notification_update_text_to_render(notification *n);
|
void notification_update_text_to_render(notification *n);
|
||||||
int notification_get_ttl(notification *n);
|
int notification_get_ttl(notification *n);
|
||||||
int notification_get_age(notification *n);
|
int notification_get_age(notification *n);
|
||||||
|
@ -32,7 +32,7 @@ TEST test_notification_is_duplicate(void *notifications)
|
|||||||
ASSERT(notification_is_duplicate(a, b));
|
ASSERT(notification_is_duplicate(a, b));
|
||||||
|
|
||||||
char *tmp = b->icon;
|
char *tmp = b->icon;
|
||||||
enum icon_position_t icon_tmp = settings.icon_position;
|
enum icon_position_t icon_setting_tmp = settings.icon_position;
|
||||||
|
|
||||||
b->icon = "Test1";
|
b->icon = "Test1";
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ TEST test_notification_is_duplicate(void *notifications)
|
|||||||
b->raw_icon = NULL;
|
b->raw_icon = NULL;
|
||||||
|
|
||||||
b->icon = tmp;
|
b->icon = tmp;
|
||||||
settings.icon_position = icon_tmp;
|
settings.icon_position = icon_setting_tmp;
|
||||||
|
|
||||||
ASSERT(notification_is_duplicate(a, b));
|
ASSERT(notification_is_duplicate(a, b));
|
||||||
|
|
||||||
@ -70,6 +70,26 @@ TEST test_notification_is_duplicate(void *notifications)
|
|||||||
PASS();
|
PASS();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST test_notification_replace_format(void)
|
||||||
|
{
|
||||||
|
char *str = g_malloc(128 * sizeof(char));
|
||||||
|
|
||||||
|
strcpy(str, "Testing format replacement");
|
||||||
|
ASSERT_STR_EQ("Testing text replacement", (str = notification_replace_format("format", "text", str, MARKUP_FULL)));
|
||||||
|
|
||||||
|
strcpy(str, "Markup %a preserved");
|
||||||
|
ASSERT_STR_EQ("Markup and & <i>is</i> preserved", (str = notification_replace_format("%a", "and & <i>is</i>", str, MARKUP_FULL)));
|
||||||
|
|
||||||
|
strcpy(str, "Markup %a escaped");
|
||||||
|
ASSERT_STR_EQ("Markup and & <i>is</i> escaped", (str = notification_replace_format("%a", "and & <i>is</i>", str, MARKUP_NO)));
|
||||||
|
|
||||||
|
strcpy(str, "Markup %a");
|
||||||
|
ASSERT_STR_EQ("Markup is removed and & escaped", (str = notification_replace_format("%a", "<i>is removed</i> and & escaped", str, MARKUP_STRIP)));
|
||||||
|
|
||||||
|
g_free(str);
|
||||||
|
PASS();
|
||||||
|
}
|
||||||
|
|
||||||
SUITE(suite_notification)
|
SUITE(suite_notification)
|
||||||
{
|
{
|
||||||
cmdline_load(0, NULL);
|
cmdline_load(0, NULL);
|
||||||
@ -89,6 +109,10 @@ SUITE(suite_notification)
|
|||||||
notification *n[2] = {a, b};
|
notification *n[2] = {a, b};
|
||||||
|
|
||||||
RUN_TEST1(test_notification_is_duplicate, (void*) n);
|
RUN_TEST1(test_notification_is_duplicate, (void*) n);
|
||||||
|
g_free(a);
|
||||||
|
g_free(b);
|
||||||
|
|
||||||
|
RUN_TEST(test_notification_replace_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user