diff -r c1fb4e53da4e -r 826f5da7b56c libpurple/protocols/yahoo/tests/test_yahoo_util.c --- a/libpurple/protocols/yahoo/tests/test_yahoo_util.c Sun May 28 13:26:27 2017 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,250 +0,0 @@ -#include - -#include "../ymsg.h" - -typedef struct { - gchar *input; - gchar *output; -} YahooStringTestData; - -static void -test_codes_to_html(void) { - YahooStringTestData data[] = { - { - "", - "", - }, { - "\x1B[12345m", - "", - }, { - "plain", - "plain", - }, { - "unknown \x1B[12345m ansi code", - "unknown ansi code", - }, { - "plain ", - "plain <peanut>", - }, { - "plain peanut", - "plain> peanut", - }, { - "test", - "test", - }, { - "blue", - }, { - "\x1B[#70ea15mcustom color", - "custom color", - }, { - "test", - "test", - }, { - /* font face */ - "test", - "test", - }, { - /* font size */ - "test", - "test", - }, { - "size 32", - "size 32", - }, { - /* combinations */ - "test", - "test", - }, { - "\x1B[35mtest", - "test", - }, { - ":<", - ":<", - }, { - NULL, - NULL, - } - }; - gint i; - - yahoo_init_colorht(); - - for(i = 0; data[i].input; i++) { - gchar *result = yahoo_codes_to_html(data[i].input); - - g_assert_cmpstr(result, ==, data[i].output); - - g_free(result); - } - - yahoo_dest_colorht(); -} - -static void -test_html_to_codes(void) { - YahooStringTestData data[] = { - { - "plain", - "plain", - }, { - "plain <peanut>", - "plain ", - }, { - "plain <peanut", - "plain peanut", - }, { - "plain >", - "plain >", - }, { - "plain > ", - "plain > ", - }, { - "plain <", - "plain <", - }, { - "plain < ", - "plain < ", - }, { - "plain <", - "plain <", - }, { - "plain &", - "plain &", - }, { - /* bold/italic/underline */ - "bold", - "\x1B[1mbold\x1B[x1m", - }, { - "italic", - "\x1B[2mitalic\x1B[x2m", - }, { - "underline", - "\x1B[4munderline\x1B[x4m", - }, { - "no markup", - "no markup", - }, { - "bold italic underline", - "\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline\x1B[x4m", - }, { - "bold bolditalic italic", - "\x1B[1mbold \x1B[2mbolditalic\x1B[x2m\x1B[x1m\x1B[2m italic\x1B[x2m", - }, { - "bold bolditalic italicunderline", - "\x1B[1mbold \x1B[2mbolditalic\x1B[x2m\x1B[x1m\x1B[2m \x1B[4mitalicunderline\x1B[x4m\x1B[x2m", - }, { - /* link */ - "https://pidgin.im/", - "https://pidgin.im/", - }, { - "mark@example.com", - "mark@example.com", - }, { - /* font nothing */ - "nothing", - "nothing", - }, { - /* font color */ - "red", - "\x1B[#E71414mred\x1B[#000000m", - }, { - "red blue black", - "\x1B[#FF0000mred\x1B[#000000m \x1B[#0000FFmblue\x1B[#000000m black", - }, { - /* font size */ - "test", - "test", - }, { - "test", - "test", - }, { - /* combinations */ - "redsmall rednormal", - "\x1B[#FF0000mredsmall rednormal\x1B[#000000m", - }, { - "redsmall greennormal rednormal", - "\x1B[#FF0000mredsmall \x1B[#00FF00mgreennormal\x1B[#FF0000m rednormal\x1B[#000000m", - }, { - "bold red larger backtoblack normalsize", - "\x1B[1mbold \x1B[#FF0000mred larger \x1B[#000000mbacktoblack normalsize\x1B[#FF0000m\x1B[#000000m\x1B[x1m", - }, { - /* buzz/unknown tags */ - "", - "", - }, { - "Unknown ", - "Unknown ", - }, { - NULL, - NULL, - } - }; - gint i; - - yahoo_init_colorht(); - - for(i = 0; data[i].input; i++) { - gchar *result = yahoo_html_to_codes(data[i].input); - - g_assert_cmpstr(result, ==, data[i].output); - - g_free(result); - } - - yahoo_dest_colorht(); -} - -gint -main(gint argc, gchar **argv) { - g_test_init(&argc, &argv, NULL); - - g_test_add_func("/yahoo/format/network to html", - test_codes_to_html); - g_test_add_func("/yahoo/format/html to network", - test_html_to_codes); - - return g_test_run(); -}