mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 15:03:39 +02:00
gtestutils: forbid having two tests with the same full path
In the same way that gtestutils used to let you create multiple suites with the same name, it also let you create multiple tests with the same name. Make that an error instead (and fix glib/tests/base64.c, which was registering three separate tests named "/base64/incremental/nobreak/4", and glib/tests/autoptr.c, which was running test_g_variant_builder() twice). https://bugzilla.gnome.org/show_bug.cgi?id=754286
This commit is contained in:
@@ -1647,6 +1647,15 @@ find_suite (gconstpointer l, gconstpointer s)
|
||||
return strcmp (suite->name, str);
|
||||
}
|
||||
|
||||
static gint
|
||||
find_case (gconstpointer l, gconstpointer s)
|
||||
{
|
||||
const GTestCase *tc = l;
|
||||
const gchar *str = s;
|
||||
|
||||
return strcmp (tc->name, str);
|
||||
}
|
||||
|
||||
/**
|
||||
* GTestFixtureFunc:
|
||||
* @fixture: the test fixture
|
||||
@@ -1712,7 +1721,12 @@ g_test_add_vtable (const char *testpath,
|
||||
}
|
||||
else /* islast */
|
||||
{
|
||||
GTestCase *tc = g_test_create_case (seg, data_size, test_data, data_setup, fixture_test_func, data_teardown);
|
||||
GTestCase *tc;
|
||||
|
||||
if (g_slist_find_custom (suite->cases, seg, find_case))
|
||||
g_error ("duplicate test case path: %s", testpath);
|
||||
|
||||
tc = g_test_create_case (seg, data_size, test_data, data_setup, fixture_test_func, data_teardown);
|
||||
g_test_suite_add (suite, tc);
|
||||
}
|
||||
}
|
||||
|
@@ -438,7 +438,6 @@ main (int argc, gchar *argv[])
|
||||
g_test_add_func ("/autoptr/g_tree", test_g_tree);
|
||||
g_test_add_func ("/autoptr/g_variant", test_g_variant);
|
||||
g_test_add_func ("/autoptr/g_variant_builder", test_g_variant_builder);
|
||||
g_test_add_func ("/autoptr/g_variant_builder", test_g_variant_builder);
|
||||
g_test_add_func ("/autoptr/g_variant_iter", test_g_variant_iter);
|
||||
g_test_add_func ("/autoptr/g_variant_dict", test_g_variant_dict);
|
||||
g_test_add_func ("/autoptr/g_variant_type", test_g_variant_type);
|
||||
|
@@ -394,9 +394,9 @@ main (int argc, char *argv[])
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/3", GINT_TO_POINTER (DATA_SIZE - 2), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/break/3", GINT_TO_POINTER (DATA_SIZE - 2), test_incremental_break);
|
||||
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (1), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (2), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4", GINT_TO_POINTER (3), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4-a", GINT_TO_POINTER (1), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4-b", GINT_TO_POINTER (2), test_incremental_nobreak);
|
||||
g_test_add_data_func ("/base64/incremental/nobreak/4-c", GINT_TO_POINTER (3), test_incremental_nobreak);
|
||||
|
||||
g_test_add_func ("/base64/encode", test_base64_encode);
|
||||
g_test_add_func ("/base64/decode", test_base64_decode);
|
||||
|
Reference in New Issue
Block a user