g_tree_foreach (tree, my_traverse, NULL);
g_print ("\n");
}
+
+ g_tree_unref (tree);
}
static gboolean
static void
test_g_parse_debug_string (void)
{
- GDebugKey keys[3] = {
+ GDebugKey keys[] = {
{ "foo", 1 },
{ "bar", 2 },
- { "baz", 4 }
+ { "baz", 4 },
+ { "weird", 8 },
};
- guint n_keys = 3;
+ guint n_keys = G_N_ELEMENTS (keys);
guint result;
result = g_parse_debug_string ("bar:foo:blubb", keys, n_keys);
result = g_parse_debug_string (" : ", keys, n_keys);
g_assert (result == 0);
+
+ result = g_parse_debug_string ("all", keys, n_keys);
+ g_assert_cmpuint (result, ==, (1 << n_keys) - 1);
+
+ /* Test subtracting debug flags from "all" */
+ result = g_parse_debug_string ("all:foo", keys, n_keys);
+ g_assert_cmpuint (result, ==, 2 | 4 | 8);
+
+ result = g_parse_debug_string ("foo baz,all", keys, n_keys);
+ g_assert_cmpuint (result, ==, 2 | 8);
+
+ result = g_parse_debug_string ("all,fooo,baz", keys, n_keys);
+ g_assert_cmpuint (result, ==, 1 | 2 | 8);
+
+ result = g_parse_debug_string ("all:weird", keys, n_keys);
+ g_assert_cmpuint (result, ==, 1 | 2 | 4);
}
static void
remove (template);
error = NULL;
+ name_used = NULL;
strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX");
fd = g_file_open_tmp (template, &name_used, &error);
if (g_test_verbose())
else
g_print ("g_file_open_tmp correctly returns error: %s\n", error->message);
}
- close (fd);
+ if (fd != -1)
+ close (fd);
g_clear_error (&error);
+ g_free (name_used);
#ifdef G_OS_WIN32
+ name_used = NULL;
strcpy (template, "zap/barXXXXXX");
fd = g_file_open_tmp (template, &name_used, &error);
if (g_test_verbose())
}
close (fd);
g_clear_error (&error);
+ g_free (name_used);
#endif
strcpy (template, "zapXXXXXX");
+ name_used = NULL;
fd = g_file_open_tmp (template, &name_used, &error);
if (fd == -1)
g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
close (fd);
g_clear_error (&error);
remove (name_used);
+ g_free (name_used);
+ name_used = NULL;
fd = g_file_open_tmp (NULL, &name_used, &error);
if (fd == -1)
g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
close (fd);
g_clear_error (&error);
remove (name_used);
+ g_free (name_used);
}
static void
}
for (i = 0; i < 10000; i++)
g_mem_chunk_free (mem_chunk, mem[i]);
+
+ g_mem_chunk_destroy (mem_chunk);
}
#endif