Commit e773acfe authored by Matthias Clasen's avatar Matthias Clasen

tests: Don't test g_utf8_to_ucs4_fast too rigorously

The function is documented to assume valid input, and doesn't
guarantee behavior with invalid input. So don't test that.

https://bugzilla.gnome.org/show_bug.cgi?id=754636
parent db3ffe5b
......@@ -77,6 +77,16 @@ utf16_count (gunichar2 *a)
return result;
}
static void
print_ucs4 (const gchar *prefix, gunichar *ucs4, gint ucs4_len)
{
gint i;
g_print ("%s ", prefix);
for (i = 0; i < ucs4_len; i++)
g_print ("%x ", ucs4[i]);
g_print ("\n");
}
static void
process (gint line,
gchar *utf8,
......@@ -112,7 +122,7 @@ process (gint line,
if (status == INCOMPLETE)
{
gunichar *ucs4_result;
gunichar *ucs4_result;
ucs4_result = g_utf8_to_ucs4 (utf8, -1, NULL, NULL, &error);
......@@ -137,31 +147,40 @@ process (gint line,
if (status == VALID || status == NOTUNICODE)
{
gunichar *ucs4_result;
gchar *utf8_result;
ucs4_result = g_utf8_to_ucs4 (utf8, -1, &items_read, &items_written, &error);
if (!ucs4_result)
{
fail ("line %d: conversion to ucs4 failed: %s\n", line, error->message);
fail ("line %d: conversion with status %d to ucs4 failed: %s\n", line, status, error->message);
return;
}
if (!ucs4_equal (ucs4_result, ucs4) ||
items_read != strlen (utf8) ||
items_written != ucs4_len)
{
fail ("line %d: results of conversion to ucs4 do not match expected.\n", line);
fail ("line %d: results of conversion with status %d to ucs4 do not match expected.\n", line, status);
print_ucs4 ("expected: ", ucs4, ucs4_len);
print_ucs4 ("received: ", ucs4_result, items_written);
return;
}
g_free (ucs4_result);
}
if (status == VALID)
{
gunichar *ucs4_result;
gchar *utf8_result;
ucs4_result = g_utf8_to_ucs4_fast (utf8, -1, &items_written);
if (!ucs4_equal (ucs4_result, ucs4) ||
items_written != ucs4_len)
{
fail ("line %d: results of fast conversion to ucs4 do not match expected.\n", line);
fail ("line %d: results of fast conversion with status %d to ucs4 do not match expected.\n", line, status);
print_ucs4 ("expected: ", ucs4, ucs4_len);
print_ucs4 ("received: ", ucs4_result, items_written);
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment