mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-08 02:16:17 +01:00
Merge branch 'cleanup-warnings-split-4' into 'main'
Cleanup warnings split 4 See merge request GNOME/glib!2493
This commit is contained in:
commit
60bbf27c45
@ -179,13 +179,13 @@ test_dataset_id (void)
|
||||
g_assert (ret == NULL);
|
||||
}
|
||||
|
||||
static GData *list;
|
||||
static GData *global_list;
|
||||
|
||||
static void
|
||||
free_one (gpointer data)
|
||||
{
|
||||
/* recurse */
|
||||
g_datalist_clear (&list);
|
||||
g_datalist_clear (&global_list);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -194,11 +194,11 @@ test_datalist_clear (void)
|
||||
/* Need to use a subprocess because it will deadlock if it fails */
|
||||
if (g_test_subprocess ())
|
||||
{
|
||||
g_datalist_init (&list);
|
||||
g_datalist_set_data_full (&list, "one", GINT_TO_POINTER (1), free_one);
|
||||
g_datalist_set_data_full (&list, "two", GINT_TO_POINTER (2), NULL);
|
||||
g_datalist_clear (&list);
|
||||
g_assert (list == NULL);
|
||||
g_datalist_init (&global_list);
|
||||
g_datalist_set_data_full (&global_list, "one", GINT_TO_POINTER (1), free_one);
|
||||
g_datalist_set_data_full (&global_list, "two", GINT_TO_POINTER (2), NULL);
|
||||
g_datalist_clear (&global_list);
|
||||
g_assert (global_list == NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,7 @@
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
|
||||
|
||||
int array[10000];
|
||||
static int global_array[10000];
|
||||
|
||||
static void
|
||||
fill_hash_table_and_array (GHashTable *hash_table)
|
||||
@ -45,8 +43,8 @@ fill_hash_table_and_array (GHashTable *hash_table)
|
||||
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
g_hash_table_insert (hash_table, &array[i], &array[i]);
|
||||
global_array[i] = i;
|
||||
g_hash_table_insert (hash_table, &global_array[i], &global_array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,7 +639,7 @@ test_hash_misc (void)
|
||||
verify_result_array (result_array);
|
||||
|
||||
for (i = 0; i < 10000; i++)
|
||||
g_hash_table_remove (hash_table, &array[i]);
|
||||
g_hash_table_remove (hash_table, &global_array[i]);
|
||||
|
||||
fill_hash_table_and_array (hash_table);
|
||||
|
||||
@ -971,14 +969,14 @@ set_ref_hash_test (void)
|
||||
key_unref (key2);
|
||||
}
|
||||
|
||||
GHashTable *h;
|
||||
static GHashTable *global_hashtable;
|
||||
|
||||
typedef struct {
|
||||
gchar *string;
|
||||
gboolean freed;
|
||||
} FakeFreeData;
|
||||
|
||||
GPtrArray *fake_free_data;
|
||||
static GPtrArray *fake_free_data;
|
||||
|
||||
static void
|
||||
fake_free (gpointer dead)
|
||||
@ -1003,7 +1001,7 @@ fake_free (gpointer dead)
|
||||
static void
|
||||
value_destroy_insert (gpointer value)
|
||||
{
|
||||
g_hash_table_remove_all (h);
|
||||
g_hash_table_remove_all (global_hashtable);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1016,44 +1014,44 @@ test_destroy_modify (void)
|
||||
|
||||
fake_free_data = g_ptr_array_new ();
|
||||
|
||||
h = g_hash_table_new_full (g_str_hash, g_str_equal, fake_free, value_destroy_insert);
|
||||
global_hashtable = g_hash_table_new_full (g_str_hash, g_str_equal, fake_free, value_destroy_insert);
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("a");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "b");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "b");
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("c");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "d");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "d");
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("e");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "f");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "f");
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("g");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "h");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "h");
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("h");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "k");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "k");
|
||||
|
||||
ffd = g_new0 (FakeFreeData, 1);
|
||||
ffd->string = g_strdup ("a");
|
||||
g_ptr_array_add (fake_free_data, ffd);
|
||||
g_hash_table_insert (h, ffd->string, "c");
|
||||
g_hash_table_insert (global_hashtable, ffd->string, "c");
|
||||
|
||||
g_hash_table_remove (h, "c");
|
||||
g_hash_table_remove (global_hashtable, "c");
|
||||
|
||||
/* that removed everything... */
|
||||
for (i = 0; i < fake_free_data->len; i++)
|
||||
{
|
||||
FakeFreeData *ffd = g_ptr_array_index (fake_free_data, i);
|
||||
ffd = g_ptr_array_index (fake_free_data, i);
|
||||
|
||||
g_assert (ffd->freed);
|
||||
g_free (ffd->string);
|
||||
@ -1063,9 +1061,9 @@ test_destroy_modify (void)
|
||||
g_ptr_array_unref (fake_free_data);
|
||||
|
||||
/* ... so this is a no-op */
|
||||
g_hash_table_remove (h, "e");
|
||||
g_hash_table_remove (global_hashtable, "e");
|
||||
|
||||
g_hash_table_unref (h);
|
||||
g_hash_table_unref (global_hashtable);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -525,9 +525,9 @@ test_structured_logging_roundtrip1 (void)
|
||||
if (expected_messages != NULL)
|
||||
{
|
||||
char *str;
|
||||
ExpectedMessage *expected = expected_messages->data;
|
||||
ExpectedMessage *msg = expected_messages->data;
|
||||
|
||||
str = g_log_writer_format_fields (0, expected->fields, expected->n_fields, FALSE);
|
||||
str = g_log_writer_format_fields (0, msg->fields, msg->n_fields, FALSE);
|
||||
g_test_fail_printf ("Unexpected message: %s", str);
|
||||
g_free (str);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ dispatch (GSource *source, GSourceFunc cb, gpointer date)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GSourceFuncs funcs = {
|
||||
static GSourceFuncs global_funcs = {
|
||||
prepare,
|
||||
check,
|
||||
dispatch,
|
||||
@ -63,14 +63,14 @@ test_maincontext_basic (void)
|
||||
GMainContext *ctx;
|
||||
GSource *source;
|
||||
guint id;
|
||||
gpointer data = &funcs;
|
||||
gpointer data = &global_funcs;
|
||||
|
||||
ctx = g_main_context_new ();
|
||||
|
||||
g_assert_false (g_main_context_pending (ctx));
|
||||
g_assert_false (g_main_context_iteration (ctx, FALSE));
|
||||
|
||||
source = g_source_new (&funcs, sizeof (GSource));
|
||||
source = g_source_new (&global_funcs, sizeof (GSource));
|
||||
g_assert_cmpint (g_source_get_priority (source), ==, G_PRIORITY_DEFAULT);
|
||||
g_assert_false (g_source_is_destroyed (source));
|
||||
|
||||
@ -87,7 +87,7 @@ test_maincontext_basic (void)
|
||||
g_assert_cmpstr (g_source_get_name (source), ==, "still d");
|
||||
|
||||
g_assert_null (g_main_context_find_source_by_user_data (ctx, NULL));
|
||||
g_assert_null (g_main_context_find_source_by_funcs_user_data (ctx, &funcs, NULL));
|
||||
g_assert_null (g_main_context_find_source_by_funcs_user_data (ctx, &global_funcs, NULL));
|
||||
|
||||
id = g_source_attach (source, ctx);
|
||||
g_assert_cmpint (g_source_get_id (source), ==, id);
|
||||
@ -113,18 +113,18 @@ test_maincontext_basic (void)
|
||||
g_source_unref (source);
|
||||
|
||||
ctx = g_main_context_default ();
|
||||
source = g_source_new (&funcs, sizeof (GSource));
|
||||
g_source_set_funcs (source, &funcs);
|
||||
source = g_source_new (&global_funcs, sizeof (GSource));
|
||||
g_source_set_funcs (source, &global_funcs);
|
||||
g_source_set_callback (source, cb, data, NULL);
|
||||
id = g_source_attach (source, ctx);
|
||||
g_source_unref (source);
|
||||
g_source_set_name_by_id (id, "e");
|
||||
g_assert_cmpstr (g_source_get_name (source), ==, "e");
|
||||
g_assert_true (g_source_get_context (source) == ctx);
|
||||
g_assert_true (g_source_remove_by_funcs_user_data (&funcs, data));
|
||||
g_assert_true (g_source_remove_by_funcs_user_data (&global_funcs, data));
|
||||
|
||||
source = g_source_new (&funcs, sizeof (GSource));
|
||||
g_source_set_funcs (source, &funcs);
|
||||
source = g_source_new (&global_funcs, sizeof (GSource));
|
||||
g_source_set_funcs (source, &global_funcs);
|
||||
g_source_set_callback (source, cb, data, NULL);
|
||||
id = g_source_attach (source, ctx);
|
||||
g_assert_cmpint (id, >, 0);
|
||||
@ -208,9 +208,9 @@ test_ownerless_polling (gconstpointer test_data)
|
||||
g_main_context_unref (ctx);
|
||||
}
|
||||
|
||||
static gint a;
|
||||
static gint b;
|
||||
static gint c;
|
||||
static gint global_a;
|
||||
static gint global_b;
|
||||
static gint global_c;
|
||||
|
||||
static gboolean
|
||||
count_calls (gpointer data)
|
||||
@ -235,23 +235,23 @@ test_timeouts (void)
|
||||
return;
|
||||
}
|
||||
|
||||
a = b = c = 0;
|
||||
global_a = global_b = global_c = 0;
|
||||
|
||||
ctx = g_main_context_new ();
|
||||
loop = g_main_loop_new (ctx, FALSE);
|
||||
|
||||
source = g_timeout_source_new (100);
|
||||
g_source_set_callback (source, count_calls, &a, NULL);
|
||||
g_source_set_callback (source, count_calls, &global_a, NULL);
|
||||
g_source_attach (source, ctx);
|
||||
g_source_unref (source);
|
||||
|
||||
source = g_timeout_source_new (250);
|
||||
g_source_set_callback (source, count_calls, &b, NULL);
|
||||
g_source_set_callback (source, count_calls, &global_b, NULL);
|
||||
g_source_attach (source, ctx);
|
||||
g_source_unref (source);
|
||||
|
||||
source = g_timeout_source_new (330);
|
||||
g_source_set_callback (source, count_calls, &c, NULL);
|
||||
g_source_set_callback (source, count_calls, &global_c, NULL);
|
||||
g_source_attach (source, ctx);
|
||||
g_source_unref (source);
|
||||
|
||||
@ -265,13 +265,13 @@ test_timeouts (void)
|
||||
/* We may be delayed for an arbitrary amount of time - for example,
|
||||
* it's possible for all timeouts to fire exactly once.
|
||||
*/
|
||||
g_assert_cmpint (a, >, 0);
|
||||
g_assert_cmpint (a, >=, b);
|
||||
g_assert_cmpint (b, >=, c);
|
||||
g_assert_cmpint (global_a, >, 0);
|
||||
g_assert_cmpint (global_a, >=, global_b);
|
||||
g_assert_cmpint (global_b, >=, global_c);
|
||||
|
||||
g_assert_cmpint (a, <=, 10);
|
||||
g_assert_cmpint (b, <=, 4);
|
||||
g_assert_cmpint (c, <=, 3);
|
||||
g_assert_cmpint (global_a, <=, 10);
|
||||
g_assert_cmpint (global_b, <=, 4);
|
||||
g_assert_cmpint (global_c, <=, 3);
|
||||
|
||||
g_main_loop_unref (loop);
|
||||
g_main_context_unref (ctx);
|
||||
@ -284,36 +284,36 @@ test_priorities (void)
|
||||
GSource *sourcea;
|
||||
GSource *sourceb;
|
||||
|
||||
a = b = c = 0;
|
||||
global_a = global_b = global_c = 0;
|
||||
|
||||
ctx = g_main_context_new ();
|
||||
|
||||
sourcea = g_idle_source_new ();
|
||||
g_source_set_callback (sourcea, count_calls, &a, NULL);
|
||||
g_source_set_callback (sourcea, count_calls, &global_a, NULL);
|
||||
g_source_set_priority (sourcea, 1);
|
||||
g_source_attach (sourcea, ctx);
|
||||
g_source_unref (sourcea);
|
||||
|
||||
sourceb = g_idle_source_new ();
|
||||
g_source_set_callback (sourceb, count_calls, &b, NULL);
|
||||
g_source_set_callback (sourceb, count_calls, &global_b, NULL);
|
||||
g_source_set_priority (sourceb, 0);
|
||||
g_source_attach (sourceb, ctx);
|
||||
g_source_unref (sourceb);
|
||||
|
||||
g_assert_true (g_main_context_pending (ctx));
|
||||
g_assert_true (g_main_context_iteration (ctx, FALSE));
|
||||
g_assert_cmpint (a, ==, 0);
|
||||
g_assert_cmpint (b, ==, 1);
|
||||
g_assert_cmpint (global_a, ==, 0);
|
||||
g_assert_cmpint (global_b, ==, 1);
|
||||
|
||||
g_assert_true (g_main_context_iteration (ctx, FALSE));
|
||||
g_assert_cmpint (a, ==, 0);
|
||||
g_assert_cmpint (b, ==, 2);
|
||||
g_assert_cmpint (global_a, ==, 0);
|
||||
g_assert_cmpint (global_b, ==, 2);
|
||||
|
||||
g_source_destroy (sourceb);
|
||||
|
||||
g_assert_true (g_main_context_iteration (ctx, FALSE));
|
||||
g_assert_cmpint (a, ==, 1);
|
||||
g_assert_cmpint (b, ==, 2);
|
||||
g_assert_cmpint (global_a, ==, 1);
|
||||
g_assert_cmpint (global_b, ==, 2);
|
||||
|
||||
g_assert_true (g_main_context_pending (ctx));
|
||||
g_source_destroy (sourcea);
|
||||
@ -499,7 +499,7 @@ run_inner_loop (gpointer user_data)
|
||||
GMainLoop *inner;
|
||||
GSource *timeout;
|
||||
|
||||
a++;
|
||||
global_a++;
|
||||
|
||||
inner = g_main_loop_new (ctx, FALSE);
|
||||
timeout = counter_source_new (100);
|
||||
@ -523,7 +523,7 @@ test_child_sources (void)
|
||||
ctx = g_main_context_new ();
|
||||
loop = g_main_loop_new (ctx, FALSE);
|
||||
|
||||
a = b = c = 0;
|
||||
global_a = global_b = global_c = 0;
|
||||
|
||||
parent = counter_source_new (2000);
|
||||
g_source_set_callback (parent, run_inner_loop, ctx, NULL);
|
||||
@ -531,11 +531,11 @@ test_child_sources (void)
|
||||
g_source_attach (parent, ctx);
|
||||
|
||||
child_b = counter_source_new (250);
|
||||
g_source_set_callback (child_b, count_calls, &b, NULL);
|
||||
g_source_set_callback (child_b, count_calls, &global_b, NULL);
|
||||
g_source_add_child_source (parent, child_b);
|
||||
|
||||
child_c = counter_source_new (330);
|
||||
g_source_set_callback (child_c, count_calls, &c, NULL);
|
||||
g_source_set_callback (child_c, count_calls, &global_c, NULL);
|
||||
g_source_set_priority (child_c, G_PRIORITY_HIGH);
|
||||
g_source_add_child_source (parent, child_c);
|
||||
|
||||
@ -578,9 +578,9 @@ test_child_sources (void)
|
||||
* 1110 - inner loop ends, a returns, outer loop exits
|
||||
*/
|
||||
|
||||
g_assert_cmpint (a, ==, 6);
|
||||
g_assert_cmpint (b, ==, 3);
|
||||
g_assert_cmpint (c, ==, 3);
|
||||
g_assert_cmpint (global_a, ==, 6);
|
||||
g_assert_cmpint (global_b, ==, 3);
|
||||
g_assert_cmpint (global_c, ==, 3);
|
||||
|
||||
g_source_destroy (parent);
|
||||
g_source_unref (parent);
|
||||
@ -601,17 +601,17 @@ test_recursive_child_sources (void)
|
||||
ctx = g_main_context_new ();
|
||||
loop = g_main_loop_new (ctx, FALSE);
|
||||
|
||||
a = b = c = 0;
|
||||
global_a = global_b = global_c = 0;
|
||||
|
||||
parent = counter_source_new (500);
|
||||
g_source_set_callback (parent, count_calls, &a, NULL);
|
||||
g_source_set_callback (parent, count_calls, &global_a, NULL);
|
||||
|
||||
child_b = counter_source_new (220);
|
||||
g_source_set_callback (child_b, count_calls, &b, NULL);
|
||||
g_source_set_callback (child_b, count_calls, &global_b, NULL);
|
||||
g_source_add_child_source (parent, child_b);
|
||||
|
||||
child_c = counter_source_new (430);
|
||||
g_source_set_callback (child_c, count_calls, &c, NULL);
|
||||
g_source_set_callback (child_c, count_calls, &global_c, NULL);
|
||||
g_source_add_child_source (child_b, child_c);
|
||||
|
||||
g_source_attach (parent, ctx);
|
||||
@ -635,9 +635,9 @@ test_recursive_child_sources (void)
|
||||
* 1940 b (b -> 2160, a -> 2440)
|
||||
*/
|
||||
|
||||
g_assert_cmpint (a, ==, 9);
|
||||
g_assert_cmpint (b, ==, 9);
|
||||
g_assert_cmpint (c, ==, 4);
|
||||
g_assert_cmpint (global_a, ==, 9);
|
||||
g_assert_cmpint (global_b, ==, 9);
|
||||
g_assert_cmpint (global_c, ==, 4);
|
||||
|
||||
g_source_destroy (parent);
|
||||
g_source_unref (parent);
|
||||
|
@ -31,9 +31,6 @@
|
||||
|
||||
#include "glib.h"
|
||||
|
||||
#define C2P(c) ((gpointer) ((long) (c)))
|
||||
#define P2C(p) ((gchar) ((long) (p)))
|
||||
|
||||
typedef struct {
|
||||
GString *s;
|
||||
gint count;
|
||||
@ -45,7 +42,7 @@ node_build_string (GNode *node,
|
||||
{
|
||||
CallbackData *d = data;
|
||||
|
||||
g_string_append_c (d->s, P2C (node->data));
|
||||
g_string_append_c (d->s, GPOINTER_TO_INT (node->data));
|
||||
|
||||
d->count--;
|
||||
|
||||
@ -171,22 +168,22 @@ traversal_test (void)
|
||||
gsize i;
|
||||
CallbackData data;
|
||||
|
||||
root = g_node_new (C2P ('A'));
|
||||
node_B = g_node_new (C2P ('B'));
|
||||
root = g_node_new (GINT_TO_POINTER ('A'));
|
||||
node_B = g_node_new (GINT_TO_POINTER ('B'));
|
||||
g_node_append (root, node_B);
|
||||
g_node_append_data (node_B, C2P ('E'));
|
||||
g_node_prepend_data (node_B, C2P ('C'));
|
||||
node_D = g_node_new (C2P ('D'));
|
||||
g_node_append_data (node_B, GINT_TO_POINTER ('E'));
|
||||
g_node_prepend_data (node_B, GINT_TO_POINTER ('C'));
|
||||
node_D = g_node_new (GINT_TO_POINTER ('D'));
|
||||
g_node_insert (node_B, 1, node_D);
|
||||
node_F = g_node_new (C2P ('F'));
|
||||
node_F = g_node_new (GINT_TO_POINTER ('F'));
|
||||
g_node_append (root, node_F);
|
||||
node_G = g_node_new (C2P ('G'));
|
||||
node_G = g_node_new (GINT_TO_POINTER ('G'));
|
||||
g_node_append (node_F, node_G);
|
||||
node_J = g_node_new (C2P ('J'));
|
||||
node_J = g_node_new (GINT_TO_POINTER ('J'));
|
||||
g_node_prepend (node_G, node_J);
|
||||
g_node_insert (node_G, 42, g_node_new (C2P ('K')));
|
||||
g_node_insert_data (node_G, 0, C2P ('H'));
|
||||
g_node_insert (node_G, 1, g_node_new (C2P ('I')));
|
||||
g_node_insert (node_G, 42, g_node_new (GINT_TO_POINTER ('K')));
|
||||
g_node_insert_data (node_G, 0, GINT_TO_POINTER ('H'));
|
||||
g_node_insert (node_G, 1, g_node_new (GINT_TO_POINTER ('I')));
|
||||
|
||||
/* we have built: A
|
||||
* / \
|
||||
@ -227,8 +224,8 @@ traversal_test (void)
|
||||
g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_ALL, -1, node_build_string, &data);
|
||||
g_assert_cmpstr (data.s->str, ==, "ABFEDCGKJIH");
|
||||
|
||||
g_node_append (node_D, g_node_new (C2P ('L')));
|
||||
g_node_insert (node_D, -1, g_node_new (C2P ('M')));
|
||||
g_node_append (node_D, g_node_new (GINT_TO_POINTER ('L')));
|
||||
g_node_insert (node_D, -1, g_node_new (GINT_TO_POINTER ('M')));
|
||||
|
||||
g_string_set_size (data.s, 0);
|
||||
data.count = -1;
|
||||
@ -252,31 +249,31 @@ construct_test (void)
|
||||
GNode *node_H;
|
||||
guint i;
|
||||
|
||||
root = g_node_new (C2P ('A'));
|
||||
root = g_node_new (GINT_TO_POINTER ('A'));
|
||||
g_assert_cmpint (g_node_depth (root), ==, 1);
|
||||
g_assert_cmpint (g_node_max_height (root), ==, 1);
|
||||
|
||||
node_B = g_node_new (C2P ('B'));
|
||||
node_B = g_node_new (GINT_TO_POINTER ('B'));
|
||||
g_node_append (root, node_B);
|
||||
g_assert (root->children == node_B);
|
||||
|
||||
g_node_append_data (node_B, C2P ('E'));
|
||||
g_node_prepend_data (node_B, C2P ('C'));
|
||||
node_D = g_node_new (C2P ('D'));
|
||||
g_node_append_data (node_B, GINT_TO_POINTER ('E'));
|
||||
g_node_prepend_data (node_B, GINT_TO_POINTER ('C'));
|
||||
node_D = g_node_new (GINT_TO_POINTER ('D'));
|
||||
g_node_insert (node_B, 1, node_D);
|
||||
|
||||
node_F = g_node_new (C2P ('F'));
|
||||
node_F = g_node_new (GINT_TO_POINTER ('F'));
|
||||
g_node_append (root, node_F);
|
||||
g_assert (root->children->next == node_F);
|
||||
|
||||
node_G = g_node_new (C2P ('G'));
|
||||
node_G = g_node_new (GINT_TO_POINTER ('G'));
|
||||
g_node_append (node_F, node_G);
|
||||
node_J = g_node_new (C2P ('J'));
|
||||
node_J = g_node_new (GINT_TO_POINTER ('J'));
|
||||
g_node_insert_after (node_G, NULL, node_J);
|
||||
g_node_insert (node_G, 42, g_node_new (C2P ('K')));
|
||||
node_H = g_node_new (C2P ('H'));
|
||||
g_node_insert (node_G, 42, g_node_new (GINT_TO_POINTER ('K')));
|
||||
node_H = g_node_new (GINT_TO_POINTER ('H'));
|
||||
g_node_insert_after (node_G, NULL, node_H);
|
||||
g_node_insert (node_G, 1, g_node_new (C2P ('I')));
|
||||
g_node_insert (node_G, 1, g_node_new (GINT_TO_POINTER ('I')));
|
||||
|
||||
/* we have built: A
|
||||
* / \
|
||||
@ -294,16 +291,16 @@ construct_test (void)
|
||||
g_assert_cmpint (g_node_n_nodes (root, G_TRAVERSE_ALL), ==, 11);
|
||||
g_assert_cmpint (g_node_max_height (node_F), ==, 3);
|
||||
g_assert_cmpint (g_node_n_children (node_G), ==, 4);
|
||||
g_assert (g_node_find_child (root, G_TRAVERSE_ALL, C2P ('F')) == node_F);
|
||||
g_assert (g_node_find_child (node_G, G_TRAVERSE_LEAFS, C2P ('H')) == node_H);
|
||||
g_assert (g_node_find_child (root, G_TRAVERSE_ALL, C2P ('H')) == NULL);
|
||||
g_assert (g_node_find (root, G_LEVEL_ORDER, G_TRAVERSE_NON_LEAFS, C2P ('I')) == NULL);
|
||||
g_assert (g_node_find (root, G_IN_ORDER, G_TRAVERSE_LEAFS, C2P ('J')) == node_J);
|
||||
g_assert (g_node_find_child (root, G_TRAVERSE_ALL, GINT_TO_POINTER ('F')) == node_F);
|
||||
g_assert (g_node_find_child (node_G, G_TRAVERSE_LEAFS, GINT_TO_POINTER ('H')) == node_H);
|
||||
g_assert (g_node_find_child (root, G_TRAVERSE_ALL, GINT_TO_POINTER ('H')) == NULL);
|
||||
g_assert (g_node_find (root, G_LEVEL_ORDER, G_TRAVERSE_NON_LEAFS, GINT_TO_POINTER ('I')) == NULL);
|
||||
g_assert (g_node_find (root, G_IN_ORDER, G_TRAVERSE_LEAFS, GINT_TO_POINTER ('J')) == node_J);
|
||||
|
||||
for (i = 0; i < g_node_n_children (node_B); i++)
|
||||
{
|
||||
node = g_node_nth_child (node_B, i);
|
||||
g_assert_cmpint (P2C (node->data), ==, ('C' + i));
|
||||
g_assert_cmpint (GPOINTER_TO_INT (node->data), ==, ('C' + i));
|
||||
}
|
||||
|
||||
for (i = 0; i < g_node_n_children (node_G); i++)
|
||||
@ -345,14 +342,14 @@ misc_test (void)
|
||||
GNode *node_E;
|
||||
CallbackData data;
|
||||
|
||||
root = g_node_new (C2P ('A'));
|
||||
node_B = g_node_new (C2P ('B'));
|
||||
root = g_node_new (GINT_TO_POINTER ('A'));
|
||||
node_B = g_node_new (GINT_TO_POINTER ('B'));
|
||||
g_node_append (root, node_B);
|
||||
node_D = g_node_new (C2P ('D'));
|
||||
node_D = g_node_new (GINT_TO_POINTER ('D'));
|
||||
g_node_append (root, node_D);
|
||||
node_C = g_node_new (C2P ('C'));
|
||||
node_C = g_node_new (GINT_TO_POINTER ('C'));
|
||||
g_node_insert_after (root, node_B, node_C);
|
||||
node_E = g_node_new (C2P ('E'));
|
||||
node_E = g_node_new (GINT_TO_POINTER ('E'));
|
||||
g_node_append (node_C, node_E);
|
||||
|
||||
g_assert (g_node_get_root (node_E) == root);
|
||||
@ -362,10 +359,10 @@ misc_test (void)
|
||||
g_assert (g_node_first_sibling (node_D) == node_B);
|
||||
g_assert (g_node_first_sibling (node_E) == node_E);
|
||||
g_assert (g_node_first_sibling (root) == root);
|
||||
g_assert_cmpint (g_node_child_index (root, C2P ('B')), ==, 0);
|
||||
g_assert_cmpint (g_node_child_index (root, C2P ('C')), ==, 1);
|
||||
g_assert_cmpint (g_node_child_index (root, C2P ('D')), ==, 2);
|
||||
g_assert_cmpint (g_node_child_index (root, C2P ('E')), ==, -1);
|
||||
g_assert_cmpint (g_node_child_index (root, GINT_TO_POINTER ('B')), ==, 0);
|
||||
g_assert_cmpint (g_node_child_index (root, GINT_TO_POINTER ('C')), ==, 1);
|
||||
g_assert_cmpint (g_node_child_index (root, GINT_TO_POINTER ('D')), ==, 2);
|
||||
g_assert_cmpint (g_node_child_index (root, GINT_TO_POINTER ('E')), ==, -1);
|
||||
|
||||
data.s = g_string_new ("");
|
||||
data.count = -1;
|
||||
@ -418,21 +415,21 @@ unlink_test (void)
|
||||
*
|
||||
*/
|
||||
|
||||
root = g_node_new (C2P ('a'));
|
||||
node = bnode = g_node_append_data (root, C2P ('b'));
|
||||
g_node_append_data (node, C2P ('e'));
|
||||
g_node_append_data (node, C2P ('f'));
|
||||
g_node_append_data (node, C2P ('g'));
|
||||
root = g_node_new (GINT_TO_POINTER ('a'));
|
||||
node = bnode = g_node_append_data (root, GINT_TO_POINTER ('b'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('e'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('f'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('g'));
|
||||
|
||||
node = cnode = g_node_append_data (root, C2P ('c'));
|
||||
g_node_append_data (node, C2P ('h'));
|
||||
g_node_append_data (node, C2P ('i'));
|
||||
g_node_append_data (node, C2P ('j'));
|
||||
node = cnode = g_node_append_data (root, GINT_TO_POINTER ('c'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('h'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('i'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('j'));
|
||||
|
||||
node = g_node_append_data (root, C2P ('d'));
|
||||
g_node_append_data (node, C2P ('k'));
|
||||
g_node_append_data (node, C2P ('l'));
|
||||
g_node_append_data (node, C2P ('m'));
|
||||
node = g_node_append_data (root, GINT_TO_POINTER ('d'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('k'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('l'));
|
||||
g_node_append_data (node, GINT_TO_POINTER ('m'));
|
||||
|
||||
g_node_unlink (cnode);
|
||||
|
||||
@ -473,10 +470,10 @@ copy_test (void)
|
||||
GNode *copy;
|
||||
gchar *expected;
|
||||
|
||||
root = g_node_new (C2P ('a'));
|
||||
g_node_append_data (root, C2P ('b'));
|
||||
g_node_append_data (root, C2P ('c'));
|
||||
g_node_append_data (root, C2P ('d'));
|
||||
root = g_node_new (GINT_TO_POINTER ('a'));
|
||||
g_node_append_data (root, GINT_TO_POINTER ('b'));
|
||||
g_node_append_data (root, GINT_TO_POINTER ('c'));
|
||||
g_node_append_data (root, GINT_TO_POINTER ('d'));
|
||||
|
||||
expected = "abcd";
|
||||
g_node_traverse (root, G_LEVEL_ORDER, G_TRAVERSE_ALL, -1, check_order, &expected);
|
||||
|
@ -28,15 +28,14 @@
|
||||
#include <locale.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
static GOptionEntry main_entries[] = {
|
||||
static GOptionEntry global_main_entries[] = {
|
||||
{ "main-switch", 0, 0,
|
||||
G_OPTION_ARG_NONE, NULL,
|
||||
"A switch that is in the main group", NULL },
|
||||
G_OPTION_ENTRY_NULL
|
||||
};
|
||||
|
||||
static GOptionEntry group_entries[] = {
|
||||
static GOptionEntry global_group_entries[] = {
|
||||
{ "test-switch", 0, 0,
|
||||
G_OPTION_ARG_NONE, NULL,
|
||||
"A switch that is in the test group", NULL },
|
||||
@ -54,14 +53,14 @@ make_options (int test_number)
|
||||
options = g_option_context_new (NULL);
|
||||
|
||||
if (have_main_entries)
|
||||
g_option_context_add_main_entries (options, main_entries, NULL);
|
||||
g_option_context_add_main_entries (options, global_main_entries, NULL);
|
||||
if (have_test_entries)
|
||||
{
|
||||
group = g_option_group_new ("test", "Test Options",
|
||||
"Show all test options",
|
||||
NULL, NULL);
|
||||
g_option_context_add_group (options, group);
|
||||
g_option_group_add_entries (group, group_entries);
|
||||
g_option_group_add_entries (group, global_group_entries);
|
||||
}
|
||||
|
||||
return options;
|
||||
|
@ -544,8 +544,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case GET_ITER_AT_POS:
|
||||
{
|
||||
int i;
|
||||
|
||||
g_assert (g_queue_get_length (seq->queue) == (guint) g_sequence_get_length (seq->sequence));
|
||||
|
||||
for (i = 0; i < 10; ++i)
|
||||
@ -660,7 +658,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case INSERT_SORTED:
|
||||
{
|
||||
int i;
|
||||
dump_info (seq);
|
||||
|
||||
g_sequence_sort (seq->sequence, compare_items, NULL);
|
||||
@ -683,7 +680,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case INSERT_SORTED_ITER:
|
||||
{
|
||||
int i;
|
||||
dump_info (seq);
|
||||
|
||||
g_sequence_sort (seq->sequence, compare_items, NULL);
|
||||
@ -710,8 +706,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case SORT_CHANGED:
|
||||
{
|
||||
int i;
|
||||
|
||||
g_sequence_sort (seq->sequence, compare_items, NULL);
|
||||
g_queue_sort (seq->queue, compare_iters, NULL);
|
||||
|
||||
@ -737,8 +731,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case SORT_CHANGED_ITER:
|
||||
{
|
||||
int i;
|
||||
|
||||
g_sequence_sort (seq->sequence, compare_items, NULL);
|
||||
g_queue_sort (seq->queue, compare_iters, NULL);
|
||||
|
||||
@ -765,8 +757,6 @@ run_random_tests (gconstpointer d)
|
||||
break;
|
||||
case REMOVE:
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < N_TIMES; ++i)
|
||||
{
|
||||
GList *link;
|
||||
@ -958,7 +948,6 @@ run_random_tests (gconstpointer d)
|
||||
if (!g_sequence_iter_is_end (iter))
|
||||
{
|
||||
Item *item;
|
||||
int i;
|
||||
|
||||
check_integrity (seq);
|
||||
|
||||
|
@ -40,11 +40,11 @@ static char *echo_prog_path;
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
GMainLoop *main_loop;
|
||||
guint alive;
|
||||
static GMainLoop *global_main_loop;
|
||||
static guint alive;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
char *argv0;
|
||||
static char *argv0;
|
||||
#endif
|
||||
|
||||
static GPid
|
||||
@ -98,7 +98,7 @@ child_watch_callback (GPid pid, gint status, gpointer data)
|
||||
g_spawn_close_pid (pid);
|
||||
|
||||
if (--alive == 0)
|
||||
g_main_loop_quit (main_loop);
|
||||
g_main_loop_quit (global_main_loop);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -142,7 +142,7 @@ test_spawn_childs (void)
|
||||
{
|
||||
GPid pid;
|
||||
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
global_main_loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
system ("ipconfig /all");
|
||||
@ -151,7 +151,7 @@ test_spawn_childs (void)
|
||||
#endif
|
||||
|
||||
alive = 2;
|
||||
g_timeout_add_seconds (30, quit_loop, main_loop);
|
||||
g_timeout_add_seconds (30, quit_loop, global_main_loop);
|
||||
|
||||
pid = get_a_child (10);
|
||||
g_child_watch_add (pid, (GChildWatchFunc) child_watch_callback,
|
||||
@ -160,8 +160,8 @@ test_spawn_childs (void)
|
||||
g_child_watch_add (pid, (GChildWatchFunc) child_watch_callback,
|
||||
GINT_TO_POINTER (7));
|
||||
|
||||
g_main_loop_run (main_loop);
|
||||
g_main_loop_unref (main_loop);
|
||||
g_main_loop_run (global_main_loop);
|
||||
g_main_loop_unref (global_main_loop);
|
||||
|
||||
g_assert_cmpint (alive, ==, 0);
|
||||
}
|
||||
@ -169,7 +169,7 @@ test_spawn_childs (void)
|
||||
static void
|
||||
test_spawn_childs_threads (void)
|
||||
{
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
global_main_loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
system ("ipconfig /all");
|
||||
@ -178,13 +178,13 @@ test_spawn_childs_threads (void)
|
||||
#endif
|
||||
|
||||
alive = 2;
|
||||
g_timeout_add_seconds (30, quit_loop, main_loop);
|
||||
g_timeout_add_seconds (30, quit_loop, global_main_loop);
|
||||
|
||||
g_thread_new (NULL, start_thread, GINT_TO_POINTER (3));
|
||||
g_thread_new (NULL, start_thread, GINT_TO_POINTER (7));
|
||||
|
||||
g_main_loop_run (main_loop);
|
||||
g_main_loop_unref (main_loop);
|
||||
g_main_loop_run (global_main_loop);
|
||||
g_main_loop_unref (global_main_loop);
|
||||
|
||||
g_assert_cmpint (alive, ==, 0);
|
||||
}
|
||||
|
@ -2440,15 +2440,14 @@ test_ascii_string_to_number_usual (void)
|
||||
|
||||
case UNSIGNED:
|
||||
{
|
||||
guint64 value64 = 0;
|
||||
result = g_ascii_string_to_unsigned (data->str,
|
||||
data->base,
|
||||
data->min,
|
||||
data->max,
|
||||
&value64,
|
||||
&valueu64,
|
||||
&error);
|
||||
value = value64;
|
||||
g_assert_cmpint (value, ==, value64);
|
||||
value = valueu64;
|
||||
g_assert_cmpint (value, ==, valueu64);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ typedef struct {
|
||||
gboolean valid;
|
||||
} Test;
|
||||
|
||||
Test test[] = {
|
||||
static Test global_test[] = {
|
||||
/* some tests to check max_len handling */
|
||||
/* length 1 */
|
||||
{ "abcde", -1, 5, TRUE },
|
||||
@ -364,10 +364,10 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
for (i = 0; test[i].text; i++)
|
||||
for (i = 0; global_test[i].text; i++)
|
||||
{
|
||||
path = g_strdup_printf ("/utf8/validate/%d", i);
|
||||
g_test_add_data_func (path, &test[i], do_test);
|
||||
g_test_add_data_func (path, &global_test[i], do_test);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user