changeset 27248:6271a72ba4f6

* Use our assert_string_equal() macro instead of fail_unless(strcmp(), NULL) * Fix the test_markup_html_to_xhtml test by looking for <a href=""> instead of <a href=''> I guess we changed that function to use double quotes instead of single quotes? * Add a test_mime_decode_field function (with only one test)
author Mark Doliner <mark@kingant.net>
date Thu, 02 Jul 2009 08:24:51 +0000
parents b0f0579f5f22
children 5ec78e9f8dd1
files libpurple/tests/test_util.c
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/tests/test_util.c	Thu Jul 02 08:15:49 2009 +0000
+++ b/libpurple/tests/test_util.c	Thu Jul 02 08:24:51 2009 +0000
@@ -14,7 +14,7 @@
 	gsize sz = 0;
 	guchar *out = purple_base16_decode("21646c726f77202c6f6c6c656800", &sz);
 	fail_unless(sz == 14, NULL);
-	fail_unless(strcmp("!dlrow ,olleh", (const char *)out) == 0, NULL);
+	assert_string_equal("!dlrow ,olleh", (const char *)out);
 	g_free(out);
 }
 END_TEST
@@ -30,7 +30,7 @@
 	gsize sz;
 	guchar *out = purple_base64_decode("b3d0LXl0cm9mAA==", &sz);
 	fail_unless(sz == 10, NULL);
-	fail_unless(strcmp("owt-ytrof", (const char *)out) == 0, NULL);
+	assert_string_equal("owt-ytrof", (const char *)out);
 	g_free(out);
 }
 END_TEST
@@ -94,13 +94,21 @@
 	gchar *xhtml = NULL;
 	gchar *plaintext = NULL;
 	purple_markup_html_to_xhtml("<a>", &xhtml, &plaintext);
-	fail_unless(strcmp("<a href=''></a>", xhtml) == 0, NULL);
+	assert_string_equal("<a href=\"\"></a>", xhtml);
 	g_free(xhtml);
-	fail_unless(strcmp("", plaintext) == 0, NULL);
+	assert_string_equal("", plaintext);
 	g_free(plaintext);
 }
 END_TEST
 
+START_TEST(test_mime_decode_field)
+{
+	gchar *result = purple_mime_decode_field("=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=");
+	assert_string_equal("Keld Jørn Simonsen", result);
+	g_free(result);
+}
+END_TEST
+
 Suite *
 util_suite(void)
 {
@@ -137,5 +145,9 @@
 	tcase_add_test(tc, test_markup_html_to_xhtml);
 	suite_add_tcase(s, tc);
 
+	tc = tcase_create("MIME");
+	tcase_add_test(tc, test_mime_decode_field);
+	suite_add_tcase(s, tc);
+
 	return s;
 }