/** * remove: * * Test that it is possible to remove data identified by the ID: **/ static void remove (GimpTestFixture *f, gconstpointer data) { gint ret_id = gimp_id_table_insert (f->id_table, data1); void *ret_data = gimp_id_table_lookup (f->id_table, ret_id); gboolean remove_successful = gimp_id_table_remove (f->id_table, ret_id); void *ret_data2 = gimp_id_table_lookup (f->id_table, ret_id); g_assert (remove_successful); g_assert (ret_data == data1); g_assert (ret_data2 == NULL); }
/** * insert_twice: * * Test that two consecutive inserts generates different IDs. **/ static void insert_twice (GimpTestFixture *f, gconstpointer data) { gint ret_id = gimp_id_table_insert (f->id_table, data1); gpointer ret_data = gimp_id_table_lookup (f->id_table, ret_id); gint ret_id2 = gimp_id_table_insert (f->id_table, data2); gpointer ret_data2 = gimp_id_table_lookup (f->id_table, ret_id2); g_assert (ret_id != ret_id2); g_assert (ret_data == data1); g_assert (ret_data2 == data2); }
/** * insert_with_id_existing: * * Test that it is not possible to insert data with a specific ID if * that ID already is inserted. **/ static void insert_with_id_existing (GimpTestFixture *f, gconstpointer data) { const int id = 10; int ret_id = gimp_id_table_insert_with_id (f->id_table, id, data1); gpointer ret_data = gimp_id_table_lookup (f->id_table, ret_id); int ret_id2 = gimp_id_table_insert_with_id (f->id_table, id, data2); gpointer ret_data2 = gimp_id_table_lookup (f->id_table, ret_id2); g_assert (id == ret_id); g_assert (ret_id2 == -1); g_assert (ret_data == data1); g_assert (ret_data2 == NULL); }
/** * gimp_test_id_table_insert_and_lookup: * * Test that insert and lookup works. **/ static void gimp_test_id_table_insert_and_lookup (GimpTestFixture *f, gconstpointer data) { gint ret_id = gimp_id_table_insert (f->id_table, data1); gpointer ret_data = gimp_id_table_lookup (f->id_table, ret_id); g_assert (ret_data == data1); }
/** * insert_with_id: * * Test that it is possible to insert data with a specific ID. **/ static void insert_with_id (GimpTestFixture *f, gconstpointer data) { const int id = 10; int ret_id = gimp_id_table_insert_with_id (f->id_table, id, data1); gpointer ret_data = gimp_id_table_lookup (f->id_table, id); g_assert (ret_id == id); g_assert (ret_data == data1); }
/** * remove_non_existing: * * Tests that things work properly when trying to remove data with an * ID that doesn't exist. **/ static void remove_non_existing (GimpTestFixture *f, gconstpointer data) { const int id = 10; gboolean remove_successful = gimp_id_table_remove (f->id_table, id); void *ret_data = gimp_id_table_lookup (f->id_table, id); g_assert (! remove_successful); g_assert (ret_data == NULL); }
/** * replace: * * Test that it is possible to replace data with a given ID with * different data. **/ static void replace (GimpTestFixture *f, gconstpointer data) { int ret_id = gimp_id_table_insert (f->id_table, data1); gpointer ret_data; gimp_id_table_replace (f->id_table, ret_id, data2); ret_data = gimp_id_table_lookup (f->id_table, ret_id); g_assert (ret_data == data2); }
/** * replace_as_insert: * * Test that replace works like insert when there is no data to * replace. **/ static void replace_as_insert (GimpTestFixture *f, gconstpointer data) { const int id = 10; gpointer ret_data; gimp_id_table_replace (f->id_table, id, data1); ret_data = gimp_id_table_lookup (f->id_table, id); g_assert (ret_data == data1); }