From: Matthias Clasen Date: Thu, 6 Oct 2011 03:31:14 +0000 (-0400) Subject: Improve GCache test coverage X-Git-Tag: 2.31.0~189 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dca6a601c13798dde689cab7f9ac67db2765ae2d;p=platform%2Fupstream%2Fglib.git Improve GCache test coverage --- diff --git a/glib/tests/cache.c b/glib/tests/cache.c index 364bb7d..5ece83d 100644 --- a/glib/tests/cache.c +++ b/glib/tests/cache.c @@ -88,6 +88,17 @@ key_foreach (gpointer valuep, gpointer keyp, gpointer data) } static void +value_foreach (gpointer keyp, gpointer nodep, gpointer data) +{ + gint *count = data; + gint *key = keyp; + + (*count)++; + + g_assert_cmpint (*key, ==, 2); +} + +static void test_cache_basic (void) { GCache *c; @@ -114,6 +125,10 @@ test_cache_basic (void) g_cache_key_foreach (c, key_foreach, &count); g_assert_cmpint (count, ==, 1); + count = 0; + g_cache_value_foreach (c, value_foreach, &count); + g_assert_cmpint (count, ==, 1); + value = g_cache_insert (c, key); g_assert_cmpint (*value, ==, 4); g_assert_cmpint (value_create_count, ==, 1);