diff options
-rw-r--r-- | tests/test-common.c | 26 | ||||
-rw-r--r-- | tests/test-common.h | 4 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/test-common.c b/tests/test-common.c index 0f70a8bfa..01a0c3877 100644 --- a/tests/test-common.c +++ b/tests/test-common.c @@ -113,3 +113,29 @@ pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error) return TRUE; } + +void +add_test_for_all_images (const gchar *prefix, + const gchar *path, + GTestDataFunc test_func) +{ + GDir *dir; + const gchar *name; + + dir = g_dir_open (path, 0, NULL); + while ((name = g_dir_read_name (dir)) != NULL) + { + gchar *test_path; + gchar *dir_path; + + test_path = g_strconcat (prefix, "/", name, NULL); + dir_path = g_strconcat (path, "/", name, NULL); + if (g_file_test (dir_path, G_FILE_TEST_IS_DIR)) + add_test_for_all_images (test_path, dir_path, test_func); + else + g_test_add_data_func_full (test_path, g_strdup (dir_path), test_func, g_free); + g_free (test_path); + g_free (dir_path); + } + g_dir_close (dir); +} diff --git a/tests/test-common.h b/tests/test-common.h index 0514cd757..5c8e3e7a4 100644 --- a/tests/test-common.h +++ b/tests/test-common.h @@ -30,6 +30,10 @@ G_BEGIN_DECLS gboolean format_supported (const gchar *filename); gboolean skip_if_insufficient_memory (GError **err); gboolean pixdata_equal (GdkPixbuf *p1, GdkPixbuf *p2, GError **error); +void add_test_for_all_images (const gchar *prefix, + const gchar *dir, + GTestDataFunc test_func); + G_END_DECLS |