/pidgin/main: 684c245c52fa: Initial attempt at updating the yaho...
Gary Kramlich <[email protected]>
| Newsgroups | gmane.comp.gnome.gaim.cvs |
|---|---|
| Message-ID | <[email protected]> |
Changeset: 684c245c52fa80cebddd0558ee2e09aa6be58bad Author: Gary Kramlich <[email protected]> Date: 2016-03-11 23:24 -0600 Branch: default URL: https://hg.pidgin.im/pidgin/main/rev/684c245c52fa Description: Initial attempt at updating the yahoo tests, but somehome I'm hitting dbus (?!) and it's failing diffstat: .hgignore | 1 + configure.ac | 1 + libpurple/protocols/yahoo/Makefile.am | 2 + libpurple/protocols/yahoo/tests/.hgignore | 7 + libpurple/protocols/yahoo/tests/Makefile.am | 23 + libpurple/protocols/yahoo/tests/test_yahoo_util.c | 432 +++++++++++---------- 6 files changed, 266 insertions(+), 200 deletions(-) diffs (truncated from 522 to 300 lines): diff --git a/.hgignore b/.hgignore --- a/.hgignore +++ b/.hgignore @@ -150,5 +150,6 @@ stamp-h1 test-driver win32-install-dir(\.release)? +subinclude:libpurple/protocols/yahoo/tests/.hgignore subinclude:libpurple/tests/.hgignore diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2264,6 +2264,7 @@ AC_CONFIG_FILES([Makefile libpurple/protocols/silc/Makefile libpurple/protocols/simple/Makefile libpurple/protocols/yahoo/Makefile + libpurple/protocols/yahoo/tests/Makefile libpurple/protocols/zephyr/Makefile libpurple/tests/Makefile libpurple/purple.h diff --git a/libpurple/protocols/yahoo/Makefile.am b/libpurple/protocols/yahoo/Makefile.am --- a/libpurple/protocols/yahoo/Makefile.am +++ b/libpurple/protocols/yahoo/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = tests + EXTRA_DIST = \ Makefile.mingw diff --git a/libpurple/protocols/yahoo/tests/.hgignore b/libpurple/protocols/yahoo/tests/.hgignore new file mode 100644 --- /dev/null +++ b/libpurple/protocols/yahoo/tests/.hgignore @@ -0,0 +1,7 @@ +syntax: regexp +^test_yahoo_util$ + +syntax: glob +*.log +*.trs + diff --git a/libpurple/protocols/yahoo/tests/Makefile.am b/libpurple/protocols/yahoo/tests/Makefile.am new file mode 100644 --- /dev/null +++ b/libpurple/protocols/yahoo/tests/Makefile.am @@ -0,0 +1,23 @@ +include $(top_srcdir)/glib-tap.mk + +COMMON_LIBS=\ + $(top_builddir)/libpurple/libpurple.la \ + $(top_builddir)/libpurple/protocols/yahoo/libyahoo.la \ + $(GLIB_LIBS) \ + $(GPLUGIN_LIBS) + +test_programs=\ + test_yahoo_util + +test_yahoo_util_SOURCES=test_yahoo_util.c +test_yahoo_util_LDADD=$(COMMON_LIBS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/libpurple \ + -I$(top_builddir)/libpurple \ + $(DEBUG_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GPLUGIN_CFLAGS) \ + $(PLUGIN_CFLAGS) \ + $(DBUS_CFLAGS) \ + $(NSS_CFLAGS) diff --git a/libpurple/tests/test_yahoo_util.c b/libpurple/protocols/yahoo/tests/test_yahoo_util.c rename from libpurple/tests/test_yahoo_util.c rename to libpurple/protocols/yahoo/tests/test_yahoo_util.c --- a/libpurple/tests/test_yahoo_util.c +++ b/libpurple/protocols/yahoo/tests/test_yahoo_util.c @@ -1,214 +1,246 @@ -#include <string.h> +#include <glib.h> -#include "tests.h" -#include "../protocols/yahoo/ymsg.h" +#include "../ymsg.h" -static void setup_codes_to_html(void) -{ +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 <peanut>", + "plain <peanut>", + }, { + "plain <peanut", + "plain <peanut", + }, { + "plain> peanut", + "plain> peanut", + }, { + "<font face='inva>lid'>test", + "<font face='inva>lid'>test</font>", + }, { + "<font face='inva>lid", + "<font face='inva>lid", + }, { + "\x1B[1mbold", + "<b>bold</b>", + }, { + "\x1B[2mitalic", + "<i>italic</i>", + }, { + "\x1B[4munderline", + "<u>underline</u>", + }, { + "no\x1B[x4m markup", + "no markup", + }, { + /* bold italic underline */ + "\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline", + "<b>bold</b> <i>italic</i> <u>underline</u>", + }, { + "\x1B[1mbold \x1B[2mbolditalic\x1B[x1m italic", + "<b>bold <i>bolditalic</i></b><i> italic</i>", + }, { + "\x1B[1mbold \x1B[2mbolditalic\x1B[x1m \x1B[4mitalicunderline", + "<b>bold <i>bolditalic</i></b><i> <u>italicunderline</u></i>", + }, { + "\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x2m boldunderline", + "<b>bold <i>bolditalic <u>bolditalicunderline</u></i><u> boldunderline</u></b>", + }, { + "\x1B[1mbold \x1B[2mbolditalic \x1B[4mbolditalicunderline\x1B[x1m italicunderline", + "<b>bold <i>bolditalic <u>bolditalicunderline</u></i></b><i><u> italicunderline</u></i>", + }, { + /* links */ + "\x1B[lmhttps://pidgin.im/\x1B[xlm", + "https://pidgin.im/", + }, { + /* font color */ + "\x1B[31mblue", + "<font color='#0000FF'>blue</font>", + }, { + "\x1B[#70ea15mcustom color", + "<font color='#70ea15'>custom color</font>", + }, { + "<ALT #ff0000,#00ff00,#0000ff>test</ALT>", + "test", + }, { + /* font face */ + "<font face='Georgia'>test", + "<font face='Georgia'>test</font>", + }, { + /* font size */ + "<font size='15'>test", + "<font size='4' absz='15'>test</font>", + }, { + "<font size='32'>size 32", + "<font size='6' absz='32'>size 32</font>", + }, { + /* combinations */ + "<font face='Georgia' size='32'>test", + "<font face='Georgia' size='6' absz='32'>test</font>", + }, { + "\x1B[35m<font size='15'>test", + "<font color='#FF0080'><font size='4' absz='15'>test</font></font>", + }, { + "<FADE #ff0000,#00ff00,#0000ff>:<</FADE>", + ":<", + }, { + NULL, + NULL, + } + }; + gint i; + yahoo_init_colorht(); -} -static void teardown_codes_to_html(void) -{ + 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(); } -START_TEST(test_codes_to_html) -{ - assert_string_equal_free("", - yahoo_codes_to_html("")); - assert_string_equal_free("", - yahoo_codes_to_html("\x1B[12345m")); - assert_string_equal_free("plain", - yahoo_codes_to_html("plain")); - assert_string_equal_free("unknown ansi code", - yahoo_codes_to_html("unknown \x1B[12345m ansi code")); - assert_string_equal_free("plain <peanut>", - yahoo_codes_to_html("plain <peanut>")); - assert_string_equal_free("plain <peanut", - yahoo_codes_to_html("plain <peanut")); - assert_string_equal_free("plain> peanut", - yahoo_codes_to_html("plain> peanut")); - assert_string_equal_free("<font face='inva>lid'>test</font>", - yahoo_codes_to_html("<font face='inva>lid'>test")); - assert_string_equal_free("<font face='inva>lid", - yahoo_codes_to_html("<font face='inva>lid")); +static void +test_html_to_codes(void) { + YahooStringTestData data[] = { + { + "plain", + "plain", + }, { + "plain <peanut>", + "plain <peanut>", + }, { + "plain <peanut", + "plain <peanut", + }, { + "plain> peanut", + "plain> peanut", + }, { + "plain >", + "plain >", + }, { + "plain > ", + "plain > ", + }, { + "plain <", + "plain <", + }, { + "plain < ", + "plain < ", + }, { + "plain <", + "plain <", + }, { + "plain &", + "plain &", + }, { + /* bold/italic/underline */ + "<b>bold</b>", + "\x1B[1mbold\x1B[x1m", + }, { + "<i>italic</i>", + "\x1B[2mitalic\x1B[x2m", + }, { + "<u>underline</u>", + "\x1B[4munderline\x1B[x4m", + }, { + "no</u> markup", + "no markup", + }, { + "<b>bold</b> <i>italic</i> <u>underline</u>", + "\x1B[1mbold\x1B[x1m \x1B[2mitalic\x1B[x2m \x1B[4munderline\x1B[x4m", + }, { + "<b>bold <i>bolditalic</i></b><i> italic</i>", + "\x1B[1mbold \x1B[2mbolditalic\x1B[x2m\x1B[x1m\x1B[2m italic\x1B[x2m", + }, { + "<b>bold <i>bolditalic</i></b><i> <u>italicunderline</u></i>", + "\x1B[1mbold \x1B[2mbolditalic\x1B[x2m\x1B[x1m\x1B[2m \x1B[4mitalicunderline\x1B[x4m\x1B[x2m", + }, { + /* link */ + "<A HREF=\"https://pidgin.im/\">https://pidgin.im/</A>", + "https://pidgin.im/", + }, { + "<A HREF=\"mailto:[email protected]\">[email protected]</A>", + "[email protected]", + }, { + /* font nothing */ + "<font>nothing</font>", + "nothing", + }, { + /* font color */ + "<font color=\"#E71414\">red</font>", + "\x1B[#E71414mred\x1B[#000000m", + }, { + "<font color=\"#FF0000\">red</font> <font color=\"#0000FF\">blue</font> black", + "\x1B[#FF0000mred\x1B[#000000m \x1B[#0000FFmblue\x1B[#000000m black", + }, { _______________________________________________ Commits mailing list [email protected] https://pidgin.im/cgi-bin/mailman/listinfo/commits