qulogic/gplugin

Merged in develop (pull request #8)
develop
2019-01-27, Gary Kramlich
3dee1605742e
Merged in develop (pull request #8)

Fix a bug in test-plugin-info that scanbuild found

Approved-by: Elliott Sales de Andrade
--- a/ChangeLog Sat Jan 26 13:03:54 2019 -0600
+++ b/ChangeLog Sun Jan 27 18:37:43 2019 +0000
@@ -1,5 +1,6 @@
0.28.1:
General
+ * Fix a bug that scanbuild found in test-plugin-info.
* Use g_set_error (PR #6) (Elliott Sales de Andrade)
* Use g_clear_pointer (PR #6) (Elliott Sales de Andrade)
* Use g_clear_object (PR #6) (Elliott Sales de Andrade)
--- a/gplugin/tests/test-plugin-info.c Sat Jan 26 13:03:54 2019 -0600
+++ b/gplugin/tests/test-plugin-info.c Sun Jan 27 18:37:43 2019 +0000
@@ -47,18 +47,26 @@
test_stringv(gchar **got, const gchar * const * const expected,
TestStringVFunc func, GPluginPluginInfo *info)
{
- gint i = 0;
- gchar **tmp = NULL;
+ gint i = 0;
+ gchar **tmp = NULL;
- for(i = 0; got[i]; i++)
- g_assert_cmpstr(got[i], ==, expected[i]);
+ /* make sure our arrarys are the same length */
+ g_assert_cmpuint(g_strv_length(got), ==, g_strv_length(expected));
+
+ /* now walk through until expected[i] is null comparing each entry */
+ for(i = 0; expected[i]; i++)
+ g_assert_cmpstr(got[i], ==, expected[i]);
- tmp = func(info);
+ /* call the accessor on the GPluginPluginInfo object */
+ tmp = func(info);
- for(i = 0; got[i]; i++)
- g_assert_cmpstr(got[i], ==, tmp[i]);
+ /* verify that the accessor returned the proper value as well */
+ g_assert_cmpuint(g_strv_length(tmp), ==, g_strv_length(expected));
- g_strfreev(tmp);
+ for(i = 0; expected[i]; i++)
+ g_assert_cmpstr(tmp[i], ==, expected[i]);
+
+ g_strfreev(tmp);
}
/******************************************************************************