mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-15 03:58:04 +02:00
various GLib tests: plug memory leaks
These don't really matter, since it's test code, but they do obscure real leaks in the library. Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugzilla.gnome.org/show_bug.cgi?id=666115 Acked-by: Matthias Clasen <mclasen@redhat.com>
This commit is contained in:
parent
a0f5e89aed
commit
29f2ced8eb
@ -29,11 +29,9 @@ test_load (GBookmarkFile *bookmark,
|
|||||||
|
|
||||||
res = g_bookmark_file_load_from_file (bookmark, filename, &error);
|
res = g_bookmark_file_load_from_file (bookmark, filename, &error);
|
||||||
if (error && g_test_verbose ())
|
if (error && g_test_verbose ())
|
||||||
{
|
g_print ("Load error: %s\n", error->message);
|
||||||
g_print ("Load error: %s\n", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,9 @@ test_cache_basic (void)
|
|||||||
g_assert_cmpint (value_create_count, ==, 2);
|
g_assert_cmpint (value_create_count, ==, 2);
|
||||||
g_assert_cmpint (value_destroy_count, ==, 1);
|
g_assert_cmpint (value_destroy_count, ==, 1);
|
||||||
|
|
||||||
|
g_cache_remove (c, value);
|
||||||
g_cache_destroy (c);
|
g_cache_destroy (c);
|
||||||
|
g_free (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -193,6 +193,7 @@ check_utf8_to_ucs4 (const char *utf8,
|
|||||||
g_assert (result);
|
g_assert (result);
|
||||||
for (i = 0; i <= items_written; i++)
|
for (i = 0; i <= items_written; i++)
|
||||||
g_assert (result[i] == ucs4[i]);
|
g_assert (result[i] == ucs4[i]);
|
||||||
|
g_error_free (error3);
|
||||||
}
|
}
|
||||||
else if (error_pos)
|
else if (error_pos)
|
||||||
{
|
{
|
||||||
@ -333,6 +334,7 @@ check_utf8_to_utf16 (const char *utf8,
|
|||||||
g_assert (result);
|
g_assert (result);
|
||||||
for (i = 0; i <= items_written; i++)
|
for (i = 0; i <= items_written; i++)
|
||||||
g_assert (result[i] == utf16[i]);
|
g_assert (result[i] == utf16[i]);
|
||||||
|
g_error_free (error3);
|
||||||
}
|
}
|
||||||
else if (error_pos)
|
else if (error_pos)
|
||||||
{
|
{
|
||||||
@ -407,6 +409,7 @@ check_utf16_to_utf8 (const gunichar2 *utf16,
|
|||||||
g_assert (items_written == utf8_len);
|
g_assert (items_written == utf8_len);
|
||||||
g_assert (result);
|
g_assert (result);
|
||||||
g_assert (strcmp (result, utf8) == 0);
|
g_assert (strcmp (result, utf8) == 0);
|
||||||
|
g_error_free (error3);
|
||||||
}
|
}
|
||||||
else if (error_pos)
|
else if (error_pos)
|
||||||
{
|
{
|
||||||
@ -549,6 +552,7 @@ check_utf16_to_ucs4 (const gunichar2 *utf16,
|
|||||||
g_assert (result);
|
g_assert (result);
|
||||||
for (i = 0; i <= items_written; i++)
|
for (i = 0; i <= items_written; i++)
|
||||||
g_assert (result[i] == ucs4[i]);
|
g_assert (result[i] == ucs4[i]);
|
||||||
|
g_error_free (error3);
|
||||||
}
|
}
|
||||||
else if (error_pos)
|
else if (error_pos)
|
||||||
{
|
{
|
||||||
|
@ -461,6 +461,10 @@ test_mkdir_with_parents_1 (const gchar *base)
|
|||||||
g_remove (p2);
|
g_remove (p2);
|
||||||
g_remove (p1);
|
g_remove (p1);
|
||||||
g_remove (p0);
|
g_remove (p0);
|
||||||
|
|
||||||
|
g_free (p2);
|
||||||
|
g_free (p1);
|
||||||
|
g_free (p0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -3729,6 +3729,7 @@ test_parses (void)
|
|||||||
printed = g_variant_print (value, FALSE);
|
printed = g_variant_print (value, FALSE);
|
||||||
g_assert_cmpstr (tests[i], ==, printed);
|
g_assert_cmpstr (tests[i], ==, printed);
|
||||||
g_free (printed);
|
g_free (printed);
|
||||||
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ context_pop_token (struct context *ctx)
|
|||||||
|
|
||||||
g_mutex_lock (&ctx->lock);
|
g_mutex_lock (&ctx->lock);
|
||||||
token = ctx->pending_tokens->data;
|
token = ctx->pending_tokens->data;
|
||||||
ctx->pending_tokens = g_slist_remove_link (ctx->pending_tokens,
|
ctx->pending_tokens = g_slist_delete_link (ctx->pending_tokens,
|
||||||
ctx->pending_tokens);
|
ctx->pending_tokens);
|
||||||
g_mutex_unlock (&ctx->lock);
|
g_mutex_unlock (&ctx->lock);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ main (int argc, char *argv[])
|
|||||||
GRWLock lock;
|
GRWLock lock;
|
||||||
|
|
||||||
g_rw_lock_init (&lock);
|
g_rw_lock_init (&lock);
|
||||||
|
g_rw_lock_clear (&lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1396,6 +1396,7 @@ test_page_boundary (void)
|
|||||||
g_assert_cmpint (val, ==, VALUE);
|
g_assert_cmpint (val, ==, VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_key_file_free (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -64,6 +64,7 @@ test_maincontext_basic (void)
|
|||||||
g_source_set_priority (source, G_PRIORITY_HIGH);
|
g_source_set_priority (source, G_PRIORITY_HIGH);
|
||||||
g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
|
g_assert (g_source_get_priority (source) == G_PRIORITY_HIGH);
|
||||||
|
|
||||||
|
g_source_destroy (source);
|
||||||
g_main_context_unref (ctx);
|
g_main_context_unref (ctx);
|
||||||
|
|
||||||
ctx = g_main_context_default ();
|
ctx = g_main_context_default ();
|
||||||
@ -95,6 +96,8 @@ test_mainloop_basic (void)
|
|||||||
g_main_loop_unref (loop);
|
g_main_loop_unref (loop);
|
||||||
|
|
||||||
g_assert (g_main_depth () == 0);
|
g_assert (g_main_depth () == 0);
|
||||||
|
|
||||||
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint a;
|
static gint a;
|
||||||
|
@ -176,12 +176,14 @@ test_file (const gchar *filename)
|
|||||||
if (!g_markup_parse_context_parse (context, contents, length, NULL))
|
if (!g_markup_parse_context_parse (context, contents, length, NULL))
|
||||||
{
|
{
|
||||||
g_markup_parse_context_free (context);
|
g_markup_parse_context_free (context);
|
||||||
|
g_free (contents);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_markup_parse_context_end_parse (context, NULL))
|
if (!g_markup_parse_context_end_parse (context, NULL))
|
||||||
{
|
{
|
||||||
g_markup_parse_context_free (context);
|
g_markup_parse_context_free (context);
|
||||||
|
g_free (contents);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,23 +191,40 @@ test_file (const gchar *filename)
|
|||||||
|
|
||||||
/* A byte at a time */
|
/* A byte at a time */
|
||||||
if (test_in_chunks (contents, length, 1) != 0)
|
if (test_in_chunks (contents, length, 1) != 0)
|
||||||
return 1;
|
{
|
||||||
|
g_free (contents);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* 2 bytes */
|
/* 2 bytes */
|
||||||
if (test_in_chunks (contents, length, 2) != 0)
|
if (test_in_chunks (contents, length, 2) != 0)
|
||||||
return 1;
|
{
|
||||||
|
g_free (contents);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*5 bytes */
|
/*5 bytes */
|
||||||
if (test_in_chunks (contents, length, 5) != 0)
|
if (test_in_chunks (contents, length, 5) != 0)
|
||||||
return 1;
|
{
|
||||||
|
g_free (contents);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* 12 bytes */
|
/* 12 bytes */
|
||||||
if (test_in_chunks (contents, length, 12) != 0)
|
if (test_in_chunks (contents, length, 12) != 0)
|
||||||
return 1;
|
{
|
||||||
|
g_free (contents);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* 1024 bytes */
|
/* 1024 bytes */
|
||||||
if (test_in_chunks (contents, length, 1024) != 0)
|
if (test_in_chunks (contents, length, 1024) != 0)
|
||||||
return 1;
|
{
|
||||||
|
g_free (contents);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (contents);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ mem_overflow (void)
|
|||||||
gpointer p, q;
|
gpointer p, q;
|
||||||
typedef char X[10];
|
typedef char X[10];
|
||||||
|
|
||||||
|
/* "FAIL" here apparently means "fail to overflow"... */
|
||||||
#define CHECK_PASS(P) p = (P); g_assert (p == NULL);
|
#define CHECK_PASS(P) p = (P); g_assert (p == NULL);
|
||||||
#define CHECK_FAIL(P) p = (P); g_assert (p != NULL);
|
#define CHECK_FAIL(P) p = (P); g_assert (p != NULL);
|
||||||
|
|
||||||
@ -41,24 +42,28 @@ mem_overflow (void)
|
|||||||
CHECK_PASS (g_try_malloc_n (a, b));
|
CHECK_PASS (g_try_malloc_n (a, b));
|
||||||
CHECK_PASS (g_try_malloc_n (b, a));
|
CHECK_PASS (g_try_malloc_n (b, a));
|
||||||
CHECK_FAIL (g_try_malloc_n (b, b));
|
CHECK_FAIL (g_try_malloc_n (b, b));
|
||||||
|
g_free (p);
|
||||||
|
|
||||||
CHECK_PASS (g_try_malloc0_n (a, a));
|
CHECK_PASS (g_try_malloc0_n (a, a));
|
||||||
CHECK_PASS (g_try_malloc0_n (a, b));
|
CHECK_PASS (g_try_malloc0_n (a, b));
|
||||||
CHECK_PASS (g_try_malloc0_n (b, a));
|
CHECK_PASS (g_try_malloc0_n (b, a));
|
||||||
CHECK_FAIL (g_try_malloc0_n (b, b));
|
CHECK_FAIL (g_try_malloc0_n (b, b));
|
||||||
|
g_free (p);
|
||||||
|
|
||||||
q = g_malloc (1);
|
q = g_malloc (1);
|
||||||
CHECK_PASS (g_try_realloc_n (q, a, a));
|
CHECK_PASS (g_try_realloc_n (q, a, a));
|
||||||
CHECK_PASS (g_try_realloc_n (q, a, b));
|
CHECK_PASS (g_try_realloc_n (q, a, b));
|
||||||
CHECK_PASS (g_try_realloc_n (q, b, a));
|
CHECK_PASS (g_try_realloc_n (q, b, a));
|
||||||
CHECK_FAIL (g_try_realloc_n (q, b, b));
|
CHECK_FAIL (g_try_realloc_n (q, b, b));
|
||||||
free (p);
|
g_free (p);
|
||||||
|
|
||||||
CHECK_PASS (g_try_new (X, a));
|
CHECK_PASS (g_try_new (X, a));
|
||||||
CHECK_FAIL (g_try_new (X, b));
|
CHECK_FAIL (g_try_new (X, b));
|
||||||
|
g_free (p);
|
||||||
|
|
||||||
CHECK_PASS (g_try_new0 (X, a));
|
CHECK_PASS (g_try_new0 (X, a));
|
||||||
CHECK_FAIL (g_try_new0 (X, b));
|
CHECK_FAIL (g_try_new0 (X, b));
|
||||||
|
g_free (p);
|
||||||
|
|
||||||
q = g_try_malloc (1);
|
q = g_try_malloc (1);
|
||||||
CHECK_PASS (g_try_renew (X, q, a));
|
CHECK_PASS (g_try_renew (X, q, a));
|
||||||
@ -69,7 +74,17 @@ mem_overflow (void)
|
|||||||
#undef CHECK_PASS
|
#undef CHECK_PASS
|
||||||
|
|
||||||
#define CHECK_FAIL(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_failed();
|
#define CHECK_FAIL(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_failed();
|
||||||
#define CHECK_PASS(P) if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) { p = (P); exit (0); } g_test_trap_assert_passed();
|
|
||||||
|
#define CHECK_PASS(P) do { \
|
||||||
|
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR)) \
|
||||||
|
{ \
|
||||||
|
p = (P); \
|
||||||
|
g_free (p); \
|
||||||
|
exit (0); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
g_test_trap_assert_passed(); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
CHECK_FAIL (g_malloc_n (a, a));
|
CHECK_FAIL (g_malloc_n (a, a));
|
||||||
CHECK_FAIL (g_malloc_n (a, b));
|
CHECK_FAIL (g_malloc_n (a, b));
|
||||||
@ -86,7 +101,7 @@ mem_overflow (void)
|
|||||||
CHECK_FAIL (g_realloc_n (q, a, b));
|
CHECK_FAIL (g_realloc_n (q, a, b));
|
||||||
CHECK_FAIL (g_realloc_n (q, b, a));
|
CHECK_FAIL (g_realloc_n (q, b, a));
|
||||||
CHECK_PASS (g_realloc_n (q, b, b));
|
CHECK_PASS (g_realloc_n (q, b, b));
|
||||||
free (q);
|
g_free (q);
|
||||||
|
|
||||||
CHECK_FAIL (g_new (X, a));
|
CHECK_FAIL (g_new (X, a));
|
||||||
CHECK_PASS (g_new (X, b));
|
CHECK_PASS (g_new (X, b));
|
||||||
@ -97,7 +112,7 @@ mem_overflow (void)
|
|||||||
q = g_malloc (1);
|
q = g_malloc (1);
|
||||||
CHECK_FAIL (g_renew (X, q, a));
|
CHECK_FAIL (g_renew (X, q, a));
|
||||||
CHECK_PASS (g_renew (X, q, b));
|
CHECK_PASS (g_renew (X, q, b));
|
||||||
free (q);
|
g_free (q);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -229,6 +229,8 @@ construct_test (void)
|
|||||||
|
|
||||||
for (i = 0; i < g_node_n_children (node_G); i++)
|
for (i = 0; i < g_node_n_children (node_G); i++)
|
||||||
g_assert_cmpint (g_node_child_position (node_G, g_node_nth_child (node_G, i)), ==, i);
|
g_assert_cmpint (g_node_child_position (node_G, g_node_nth_child (node_G, i)), ==, i);
|
||||||
|
|
||||||
|
g_node_destroy (root);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -45,6 +45,8 @@ test_platform_argv0 (void)
|
|||||||
g_assert (retval == TRUE);
|
g_assert (retval == TRUE);
|
||||||
g_assert (strcmp (g_get_prgname(), "option-argv0") == 0
|
g_assert (strcmp (g_get_prgname(), "option-argv0") == 0
|
||||||
|| strcmp (g_get_prgname (), "lt-option-argv0") == 0);
|
|| strcmp (g_get_prgname (), "lt-option-argv0") == 0);
|
||||||
|
|
||||||
|
g_option_context_free (context);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ group_captions (void)
|
|||||||
g_setenv ("LANG", "C", TRUE);
|
g_setenv ("LANG", "C", TRUE);
|
||||||
|
|
||||||
g_option_context_parse (options, &argc, &argv, &error);
|
g_option_context_parse (options, &argc, &argv, &error);
|
||||||
|
g_option_context_free (options);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -161,6 +162,8 @@ group_captions (void)
|
|||||||
g_test_trap_assert_stdout_unmatched ("*--help-test*");
|
g_test_trap_assert_stdout_unmatched ("*--help-test*");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_option_context_free (options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +218,9 @@ test_message (void)
|
|||||||
|
|
||||||
g_assert_cmpint (passed, ==, 3);
|
g_assert_cmpint (passed, ==, 3);
|
||||||
g_assert_cmpint (messages, ==, 3);
|
g_assert_cmpint (messages, ==, 3);
|
||||||
|
|
||||||
|
g_free (argv[1]);
|
||||||
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -317,6 +320,9 @@ test_error (void)
|
|||||||
g_error ("unexpected log message type: %s", g_test_log_type_name (msg->log_type));
|
g_error ("unexpected log message type: %s", g_test_log_type_name (msg->log_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (argv[1]);
|
||||||
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert_cmpint (messages, ==, 3);
|
g_assert_cmpint (messages, ==, 3);
|
||||||
|
@ -809,13 +809,19 @@ test_basic (void)
|
|||||||
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
|
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (5));
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
g_assert_cmpint (g_list_length (q->head), ==, 3);
|
g_assert_cmpint (g_list_length (q->head), ==, 3);
|
||||||
g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (2));
|
|
||||||
|
node = g_queue_pop_head_link (q);
|
||||||
|
g_assert (node->data == GINT_TO_POINTER (2));
|
||||||
|
g_list_free_1 (node);
|
||||||
|
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
g_assert_cmpint (g_list_length (q->head), ==, 2);
|
g_assert_cmpint (g_list_length (q->head), ==, 2);
|
||||||
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
|
g_assert (g_queue_pop_tail (q) == GINT_TO_POINTER (4));
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
g_assert_cmpint (g_list_length (q->head), ==, 1);
|
g_assert_cmpint (g_list_length (q->head), ==, 1);
|
||||||
g_assert (g_queue_pop_head_link (q)->data == GINT_TO_POINTER (3));
|
node = g_queue_pop_head_link (q);
|
||||||
|
g_assert (node->data == GINT_TO_POINTER (3));
|
||||||
|
g_list_free_1 (node);
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
g_assert_cmpint (g_list_length (q->head), ==, 0);
|
g_assert_cmpint (g_list_length (q->head), ==, 0);
|
||||||
g_assert (g_queue_pop_tail (q) == NULL);
|
g_assert (g_queue_pop_tail (q) == NULL);
|
||||||
@ -853,6 +859,7 @@ test_basic (void)
|
|||||||
node = q->tail;
|
node = q->tail;
|
||||||
g_assert (node == g_queue_pop_tail_link (q));
|
g_assert (node == g_queue_pop_tail_link (q));
|
||||||
check_integrity (q);
|
check_integrity (q);
|
||||||
|
g_list_free_1 (node);
|
||||||
g_assert_cmpint (g_list_length (q->head), ==, 3);
|
g_assert_cmpint (g_list_length (q->head), ==, 3);
|
||||||
data = q->head->data;
|
data = q->head->data;
|
||||||
g_assert (data == g_queue_pop_head (q));
|
g_assert (data == g_queue_pop_head (q));
|
||||||
@ -957,6 +964,7 @@ test_off_by_one (void)
|
|||||||
g_assert (node == NULL);
|
g_assert (node == NULL);
|
||||||
node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
|
node = g_queue_pop_nth_link (q, g_queue_get_length (q) - 1);
|
||||||
g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
|
g_assert (node != NULL && node->data == GINT_TO_POINTER (1234));
|
||||||
|
g_list_free_1 (node);
|
||||||
|
|
||||||
g_queue_free (q);
|
g_queue_free (q);
|
||||||
}
|
}
|
||||||
|
@ -1180,6 +1180,13 @@ run_random_tests (gconstpointer d)
|
|||||||
|
|
||||||
check_integrity (seq);
|
check_integrity (seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (k = 0; k < N_SEQUENCES; ++k)
|
||||||
|
{
|
||||||
|
g_queue_free (sequences[k].queue);
|
||||||
|
g_sequence_free (sequences[k].sequence);
|
||||||
|
sequences[k].n_items = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Random seeds known to have failed at one point
|
/* Random seeds known to have failed at one point
|
||||||
|
@ -841,6 +841,7 @@ test_strsplit_set (void)
|
|||||||
static void
|
static void
|
||||||
test_strv_length (void)
|
test_strv_length (void)
|
||||||
{
|
{
|
||||||
|
gchar **strv;
|
||||||
guint l;
|
guint l;
|
||||||
|
|
||||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDERR))
|
||||||
@ -849,8 +850,10 @@ test_strv_length (void)
|
|||||||
}
|
}
|
||||||
g_test_trap_assert_failed ();
|
g_test_trap_assert_failed ();
|
||||||
|
|
||||||
l = g_strv_length (g_strsplit ("1,2,3,4", ",", -1));
|
strv = g_strsplit ("1,2,3,4", ",", -1);
|
||||||
|
l = g_strv_length (strv);
|
||||||
g_assert_cmpuint (l, ==, 4);
|
g_assert_cmpuint (l, ==, 4);
|
||||||
|
g_strfreev (strv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
|
static char *locales[] = {"sv_SE", "en_US", "fa_IR", "C", "ru_RU"};
|
||||||
|
@ -454,6 +454,8 @@ test_string_up_down (void)
|
|||||||
g_string_assign (s, "Mixed Case String !?");
|
g_string_assign (s, "Mixed Case String !?");
|
||||||
g_string_up (s);
|
g_string_up (s);
|
||||||
g_assert_cmpstr (s->str, ==, "MIXED CASE STRING !?");
|
g_assert_cmpstr (s->str, ==, "MIXED CASE STRING !?");
|
||||||
|
|
||||||
|
g_string_free (s, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -466,6 +468,8 @@ test_string_set_size (void)
|
|||||||
|
|
||||||
g_assert_cmpstr (s->str, ==, "foo");
|
g_assert_cmpstr (s->str, ==, "foo");
|
||||||
g_assert_cmpint (s->len, ==, 30);
|
g_assert_cmpint (s->len, ==, 30);
|
||||||
|
|
||||||
|
g_string_free (s, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -41,6 +41,7 @@ test_seconds (void)
|
|||||||
g_timeout_add_seconds (21475, function, NULL);
|
g_timeout_add_seconds (21475, function, NULL);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint64 last_time;
|
static gint64 last_time;
|
||||||
@ -86,6 +87,7 @@ test_rounding (void)
|
|||||||
g_timeout_add_seconds (1, test_func, NULL);
|
g_timeout_add_seconds (1, test_func, NULL);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
g_main_loop_unref (loop);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -336,6 +336,7 @@ test_tree_traverse (void)
|
|||||||
g_assert_cmpstr (result, ==, "02146538A9CEDB7GIHKMLJOQPSUTRNFWYXacbZegfikjhdmonqsrpuwvzyxtlV");
|
g_assert_cmpstr (result, ==, "02146538A9CEDB7GIHKMLJOQPSUTRNFWYXacbZegfikjhdmonqsrpuwvzyxtlV");
|
||||||
|
|
||||||
g_tree_unref (tree);
|
g_tree_unref (tree);
|
||||||
|
g_free (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -60,6 +60,7 @@ test_error (void)
|
|||||||
g_assert_cmpint (errno, ==, EBADF);
|
g_assert_cmpint (errno, ==, EBADF);
|
||||||
g_assert (!res);
|
g_assert (!res);
|
||||||
g_assert_error (error, G_UNIX_ERROR, 0);
|
g_assert_error (error, G_UNIX_ERROR, 0);
|
||||||
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean sig_received = FALSE;
|
static gboolean sig_received = FALSE;
|
||||||
@ -110,6 +111,7 @@ test_signal (int signum)
|
|||||||
g_timeout_add (500, exit_mainloop, mainloop);
|
g_timeout_add (500, exit_mainloop, mainloop);
|
||||||
g_main_loop_run (mainloop);
|
g_main_loop_run (mainloop);
|
||||||
g_assert (!sig_received);
|
g_assert (!sig_received);
|
||||||
|
g_main_loop_unref (mainloop);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +140,7 @@ test_sighup_add_remove (void)
|
|||||||
g_source_remove (id);
|
g_source_remove (id);
|
||||||
kill (getpid (), SIGHUP);
|
kill (getpid (), SIGHUP);
|
||||||
g_assert (!sig_received);
|
g_assert (!sig_received);
|
||||||
|
g_main_loop_unref (mainloop);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +184,7 @@ run_to_uri_tests (void)
|
|||||||
g_assert_error (error, G_CONVERT_ERROR, to_uri_tests[i].expected_error);
|
g_assert_error (error, G_CONVERT_ERROR, to_uri_tests[i].expected_error);
|
||||||
|
|
||||||
g_free (res);
|
g_free (res);
|
||||||
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,6 +219,10 @@ run_from_uri_tests (void)
|
|||||||
else
|
else
|
||||||
g_assert_error (error, G_CONVERT_ERROR, from_uri_tests[i].expected_error);
|
g_assert_error (error, G_CONVERT_ERROR, from_uri_tests[i].expected_error);
|
||||||
g_assert_cmpstr (hostname, ==, from_uri_tests[i].expected_hostname);
|
g_assert_cmpstr (hostname, ==, from_uri_tests[i].expected_hostname);
|
||||||
|
|
||||||
|
g_free (res);
|
||||||
|
g_free (hostname);
|
||||||
|
g_clear_error (&error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,6 +290,9 @@ run_roundtrip_tests (void)
|
|||||||
|
|
||||||
g_assert (safe_strcmp_filename (to_uri_tests[i].filename, res) == 0);
|
g_assert (safe_strcmp_filename (to_uri_tests[i].filename, res) == 0);
|
||||||
g_assert (safe_strcmp_hostname (to_uri_tests[i].hostname, hostname) == 0);
|
g_assert (safe_strcmp_hostname (to_uri_tests[i].hostname, hostname) == 0);
|
||||||
|
g_free (res);
|
||||||
|
g_free (uri);
|
||||||
|
g_free (hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,12 +324,17 @@ run_uri_list_tests (void)
|
|||||||
|
|
||||||
uris = g_uri_list_extract_uris ("# just hot air\r\n# more hot air");
|
uris = g_uri_list_extract_uris ("# just hot air\r\n# more hot air");
|
||||||
g_assert_cmpint (g_strv_length (uris), ==, 0);
|
g_assert_cmpint (g_strv_length (uris), ==, 0);
|
||||||
|
g_strfreev (uris);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_uri_unescape (void)
|
test_uri_unescape (void)
|
||||||
{
|
{
|
||||||
g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F", NULL), ==, "+abc O");
|
gchar *s;
|
||||||
|
|
||||||
|
s = g_uri_unescape_string ("%2Babc %4F", NULL);
|
||||||
|
g_assert_cmpstr (s, ==, "+abc O");
|
||||||
|
g_free (s);
|
||||||
g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F", "+"), ==, NULL);
|
g_assert_cmpstr (g_uri_unescape_string ("%2Babc %4F", "+"), ==, NULL);
|
||||||
g_assert_cmpstr (g_uri_unescape_string ("%00abc %4F", "+/"), ==, NULL);
|
g_assert_cmpstr (g_uri_unescape_string ("%00abc %4F", "+/"), ==, NULL);
|
||||||
g_assert_cmpstr (g_uri_unescape_string ("%0", NULL), ==, NULL);
|
g_assert_cmpstr (g_uri_unescape_string ("%0", NULL), ==, NULL);
|
||||||
|
@ -56,6 +56,8 @@ test_define_boxed (void)
|
|||||||
g_assert_cmpstr (b->bla, ==, "bla");
|
g_assert_cmpstr (b->bla, ==, "bla");
|
||||||
|
|
||||||
g_boxed_free (MY_TYPE_BOXED, b);
|
g_boxed_free (MY_TYPE_BOXED, b);
|
||||||
|
|
||||||
|
g_free (a.bla);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -25,6 +25,7 @@ test_param_value (void)
|
|||||||
g_param_spec_unref (p2);
|
g_param_spec_unref (p2);
|
||||||
|
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
|
g_param_spec_unref (pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint destroy_count;
|
static gint destroy_count;
|
||||||
|
@ -448,6 +448,8 @@ binary_tree_test (void)
|
|||||||
g_tree_foreach (tree, my_traverse, NULL);
|
g_tree_foreach (tree, my_traverse, NULL);
|
||||||
g_print ("\n");
|
g_print ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_tree_unref (tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -943,6 +945,7 @@ test_file_functions (void)
|
|||||||
remove (template);
|
remove (template);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
name_used = NULL;
|
||||||
strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX");
|
strcpy (template, "zap" G_DIR_SEPARATOR_S "barXXXXXX");
|
||||||
fd = g_file_open_tmp (template, &name_used, &error);
|
fd = g_file_open_tmp (template, &name_used, &error);
|
||||||
if (g_test_verbose())
|
if (g_test_verbose())
|
||||||
@ -955,8 +958,10 @@ test_file_functions (void)
|
|||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
close (fd);
|
close (fd);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
g_free (name_used);
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
|
name_used = NULL;
|
||||||
strcpy (template, "zap/barXXXXXX");
|
strcpy (template, "zap/barXXXXXX");
|
||||||
fd = g_file_open_tmp (template, &name_used, &error);
|
fd = g_file_open_tmp (template, &name_used, &error);
|
||||||
if (g_test_verbose())
|
if (g_test_verbose())
|
||||||
@ -968,9 +973,11 @@ test_file_functions (void)
|
|||||||
}
|
}
|
||||||
close (fd);
|
close (fd);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
|
g_free (name_used);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
strcpy (template, "zapXXXXXX");
|
strcpy (template, "zapXXXXXX");
|
||||||
|
name_used = NULL;
|
||||||
fd = g_file_open_tmp (template, &name_used, &error);
|
fd = g_file_open_tmp (template, &name_used, &error);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
|
g_error ("g_file_open_tmp didn't work for template '%s': %s\n", template, error->message);
|
||||||
@ -979,13 +986,16 @@ test_file_functions (void)
|
|||||||
close (fd);
|
close (fd);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
remove (name_used);
|
remove (name_used);
|
||||||
|
g_free (name_used);
|
||||||
|
|
||||||
|
name_used = NULL;
|
||||||
fd = g_file_open_tmp (NULL, &name_used, &error);
|
fd = g_file_open_tmp (NULL, &name_used, &error);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
|
g_error ("g_file_open_tmp didn't work for a NULL template: %s\n", error->message);
|
||||||
close (fd);
|
close (fd);
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
remove (name_used);
|
remove (name_used);
|
||||||
|
g_free (name_used);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1553,6 +1563,8 @@ test_mem_chunks (void)
|
|||||||
}
|
}
|
||||||
for (i = 0; i < 10000; i++)
|
for (i = 0; i < 10000; i++)
|
||||||
g_mem_chunk_free (mem_chunk, mem[i]);
|
g_mem_chunk_free (mem_chunk, mem[i]);
|
||||||
|
|
||||||
|
g_mem_chunk_destroy (mem_chunk);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user