mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 19:36:18 +01:00
tests: Add some additional assertions to avoid scan-build warnings
This should avoid warnings like: ``` ../../../glib/tests/regex.c:715:7: warning: Array access (from variable 'matches') results in a null pointer dereference g_assert_cmpstr (l_exp->data, ==, matches[i]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr' const char *__s1 = (s1), *__s2 = (s2); \ ^~~~ ../../../glib/tests/regex.c:803:7: warning: Array access (from variable 'tokens') results in a null pointer dereference g_assert_cmpstr (l_exp->data, ==, tokens[i]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr' const char *__s1 = (s1), *__s2 = (s2); \ ^~~~ ../../../glib/tests/regex.c:886:7: warning: Array access (from variable 'tokens') results in a null pointer dereference g_assert_cmpstr (l_exp->data, ==, tokens[i]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr' const char *__s1 = (s1), *__s2 = (s2); \ ^~~~ ../../../glib/tests/regex.c:918:7: warning: Array access (from variable 'tokens') results in a null pointer dereference g_assert_cmpstr (l_exp->data, ==, tokens[i]); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../glib/gtestutils.h:43:79: note: expanded from macro 'g_assert_cmpstr' const char *__s1 = (s1), *__s2 = (s2); \ ^~~~ ``` Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
271db1f409
commit
2e7d3dcf70
@ -712,6 +712,7 @@ test_fetch_all (gconstpointer d)
|
|||||||
l_exp = data->expected;
|
l_exp = data->expected;
|
||||||
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (matches);
|
||||||
g_assert_cmpstr (l_exp->data, ==, matches[i]);
|
g_assert_cmpstr (l_exp->data, ==, matches[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -800,6 +801,7 @@ test_split_simple (gconstpointer d)
|
|||||||
l_exp = data->expected;
|
l_exp = data->expected;
|
||||||
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (tokens);
|
||||||
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,6 +885,7 @@ test_split_full (gconstpointer d)
|
|||||||
l_exp = data->expected;
|
l_exp = data->expected;
|
||||||
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (tokens);
|
||||||
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,6 +918,7 @@ test_split (gconstpointer d)
|
|||||||
l_exp = data->expected;
|
l_exp = data->expected;
|
||||||
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
for (i = 0; l_exp != NULL; i++, l_exp = g_slist_next (l_exp))
|
||||||
{
|
{
|
||||||
|
g_assert_nonnull (tokens);
|
||||||
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
g_assert_cmpstr (l_exp->data, ==, tokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user