#include <glib.h>
static void
-test_unref (void)
+test_maincontext_basic (void)
{
+ GMainContext *ctx;
+ GSource *source;
+ GSourceFuncs funcs;
+ guint id;
+
+ ctx = g_main_context_new ();
+
+ g_assert (!g_main_context_pending (ctx));
+ g_assert (!g_main_context_iteration (ctx, FALSE));
+
+ source = g_source_new (&funcs, sizeof (GSource));
+ g_assert (g_source_get_priority (source) == G_PRIORITY_DEFAULT);
+
+ g_assert (!g_source_get_can_recurse (source));
+ g_assert (g_source_get_name (source) == NULL);
+
+ g_source_set_can_recurse (source, TRUE);
+ g_source_set_name (source, "d");
+
+ g_assert (g_source_get_can_recurse (source));
+ g_assert_cmpstr (g_source_get_name (source), ==, "d");
+
+ g_assert (g_main_context_find_source_by_user_data (ctx, NULL) == NULL);
+ g_assert (g_main_context_find_source_by_funcs_user_data (ctx, &funcs, NULL) == NULL);
+
+ id = g_source_attach (source, ctx);
+ g_assert_cmpint (g_source_get_id (source), ==, id);
+ g_assert (g_main_context_find_source_by_id (ctx, id) == source);
+
+ g_source_set_priority (source, G_PRIORITY_HIGH);
+ g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
+
+ g_main_context_unref (ctx);
+}
+
+static void
+test_mainloop_basic (void)
+{
+ GMainLoop *loop;
+ GMainContext *ctx;
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ g_assert (!g_main_loop_is_running (loop));
+
+ g_main_loop_ref (loop);
+
+ ctx = g_main_loop_get_context (loop);
+ g_assert (ctx == g_main_context_default ());
+
+ g_main_loop_unref (loop);
+
+ g_assert (g_main_depth () == 0);
}
int
{
g_test_init (&argc, &argv, NULL);
- g_test_add_func ("/mainloop/unref", test_unref);
+ g_test_add_func ("/maincontext/basic", test_maincontext_basic);
+ g_test_add_func ("/mainloop/basic", test_mainloop_basic);
return g_test_run ();
}
* if advised of the possibility of such damage.
*/
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include <ctype.h>
#include <errno.h>
#include <locale.h>
}
}
+static void
+test_strup (void)
+{
+ gchar *s;
+
+ s = g_strdup ("lower");
+ g_assert_cmpstr (g_strup (s), ==, "LOWER");
+ g_assert_cmpstr (g_strdown (s), ==, "lower");
+ g_assert (g_strcasecmp ("lower", "LOWER") == 0);
+ g_free (s);
+}
+
int
main (int argc,
char *argv[])
g_test_add_func ("/strfuncs/strip-context", test_strip_context);
g_test_add_func ("/strfuncs/strerror", test_strerror);
g_test_add_func ("/strfuncs/strsignal", test_strsignal);
+ g_test_add_func ("/strfuncs/strup", test_strup);
return g_test_run();
}