mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Convert tests/modules-test.c to glib test framework
This commit is contained in:
parent
a20a432100
commit
f62be5660d
@ -22,11 +22,7 @@
|
||||
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#undef G_DISABLE_ASSERT
|
||||
#undef G_LOG_DOMAIN
|
||||
|
||||
#include <gmodule.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define MODULE_FILENAME_PREFIX ""
|
||||
@ -64,8 +60,7 @@ compare (const gchar *desc, const gchar *expected, const gchar *found)
|
||||
}
|
||||
|
||||
static void
|
||||
test_states (const gchar *global, const gchar *gplugin_a,
|
||||
const gchar *gplugin_b)
|
||||
test_states (const gchar *global, const gchar *gplugin_a, const gchar *gplugin_b)
|
||||
{
|
||||
compare ("global", global, global_state);
|
||||
compare ("Plugin A", gplugin_a, *gplugin_a_state);
|
||||
@ -76,9 +71,8 @@ test_states (const gchar *global, const gchar *gplugin_a,
|
||||
|
||||
static SimpleFunc plugin_clash_func = NULL;
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
static void
|
||||
test_module_basics (void)
|
||||
{
|
||||
GModule *module_self, *module_a, *module_b;
|
||||
gchar *plugin_a, *plugin_b;
|
||||
@ -86,8 +80,6 @@ main (int argc,
|
||||
GModuleFunc gmod_f;
|
||||
GError *error = NULL;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
if (!g_module_supported ())
|
||||
g_error ("dynamic modules not supported");
|
||||
|
||||
@ -129,8 +121,8 @@ main (int argc,
|
||||
g_error ("error: %s", g_module_error ());
|
||||
test_states (NULL, NULL, "check-init");
|
||||
|
||||
/* get plugin specific symbols and call them
|
||||
*/
|
||||
/* get plugin specific symbols and call them */
|
||||
|
||||
if (!g_module_symbol (module_a, "gplugin_a_func", (gpointer *) &f_a))
|
||||
g_error ("error: %s", g_module_error ());
|
||||
test_states (NULL, NULL, NULL);
|
||||
@ -145,8 +137,7 @@ main (int argc,
|
||||
f_b ();
|
||||
test_states (NULL, NULL, "Hello world");
|
||||
|
||||
/* get and call globally clashing functions
|
||||
*/
|
||||
/* get and call globally clashing functions */
|
||||
|
||||
if (!g_module_symbol (module_self, "g_clash_func", (gpointer *) &f_self))
|
||||
g_error ("error: %s", g_module_error ());
|
||||
@ -210,5 +201,14 @@ main (int argc,
|
||||
g_free (plugin_a);
|
||||
g_free (plugin_b);
|
||||
g_module_close (module_self);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/module/basics", test_module_basics);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user