mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
tests/strfuncs: handle unknown error codes when testing g_strerror
The tests checks that g_strerror returns unique error messages for all error codes between 1-200, but under Windows only a small range of them is actually used: https://msdn.microsoft.com/en-us/library/t3ayayh1.aspx Change the test to check that the returned message is either unique or matches the error message for unknown codes instead. https://bugzilla.gnome.org/show_bug.cgi?id=795569
This commit is contained in:
parent
3e5477b04b
commit
044e65ee28
@ -1324,23 +1324,29 @@ test_strip_context (void)
|
||||
g_assert (s == msgval + 7);
|
||||
}
|
||||
|
||||
/* Test the strings returned by g_strerror() are valid and unique. On Windows,
|
||||
* fewer than 200 error numbers are used, so we expect some strings to
|
||||
* return a generic ‘unknown error code’ message. */
|
||||
static void
|
||||
test_strerror (void)
|
||||
{
|
||||
GHashTable *strs;
|
||||
gint i;
|
||||
const gchar *str;
|
||||
const gchar *str, *unknown_str;
|
||||
GHashTableIter iter;
|
||||
|
||||
setlocale (LC_ALL, "C");
|
||||
|
||||
unknown_str = g_strerror (-1);
|
||||
strs = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
for (i = 1; i < 200; i++)
|
||||
{
|
||||
gboolean is_unknown;
|
||||
str = g_strerror (i);
|
||||
is_unknown = (strcmp (str, unknown_str) == 0);
|
||||
g_assert (str != NULL);
|
||||
g_assert (g_utf8_validate (str, -1, NULL));
|
||||
g_assert_false (g_hash_table_contains (strs, str));
|
||||
g_assert_true (!g_hash_table_contains (strs, str) || is_unknown);
|
||||
g_hash_table_add (strs, (char *)str);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user