Improve GCache test coverage
authorMatthias Clasen <mclasen@redhat.com>
Thu, 6 Oct 2011 03:31:14 +0000 (23:31 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 8 Oct 2011 23:02:05 +0000 (19:02 -0400)
glib/tests/cache.c

index 364bb7d..5ece83d 100644 (file)
@@ -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);