mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-08 10:26:16 +01:00
fix /list/position test
This test was exploiting unspecified behavior w.r.t. the address of string literals, It expected them to be pooled (the same literal has the same address, at least within a TU), but MSVC does not pool by default, leading to a failure.
This commit is contained in:
parent
5aafb1f21f
commit
cdd53b9218
@ -500,25 +500,29 @@ static void
|
||||
test_position (void)
|
||||
{
|
||||
GList *l, *ll;
|
||||
char *a = "a";
|
||||
char *b = "b";
|
||||
char *c = "c";
|
||||
char *d = "d";
|
||||
|
||||
l = NULL;
|
||||
l = g_list_append (l, "a");
|
||||
l = g_list_append (l, "b");
|
||||
l = g_list_append (l, "c");
|
||||
l = g_list_append (l, a);
|
||||
l = g_list_append (l, b);
|
||||
l = g_list_append (l, c);
|
||||
|
||||
ll = g_list_find (l, "a");
|
||||
ll = g_list_find (l, a);
|
||||
g_assert_cmpint (g_list_position (l, ll), ==, 0);
|
||||
g_assert_cmpint (g_list_index (l, "a"), ==, 0);
|
||||
ll = g_list_find (l, "b");
|
||||
g_assert_cmpint (g_list_index (l, a), ==, 0);
|
||||
ll = g_list_find (l, b);
|
||||
g_assert_cmpint (g_list_position (l, ll), ==, 1);
|
||||
g_assert_cmpint (g_list_index (l, "b"), ==, 1);
|
||||
ll = g_list_find (l, "c");
|
||||
g_assert_cmpint (g_list_index (l, b), ==, 1);
|
||||
ll = g_list_find (l, c);
|
||||
g_assert_cmpint (g_list_position (l, ll), ==, 2);
|
||||
g_assert_cmpint (g_list_index (l, "c"), ==, 2);
|
||||
g_assert_cmpint (g_list_index (l, c), ==, 2);
|
||||
|
||||
ll = g_list_append (NULL, "d");
|
||||
ll = g_list_append (NULL, d);
|
||||
g_assert_cmpint (g_list_position (l, ll), ==, -1);
|
||||
g_assert_cmpint (g_list_index (l, "d"), ==, -1);
|
||||
g_assert_cmpint (g_list_index (l, d), ==, -1);
|
||||
|
||||
g_list_free (l);
|
||||
g_list_free (ll);
|
||||
|
Loading…
Reference in New Issue
Block a user