diff options
Diffstat (limited to 'tests/testlinkedlist.c')
-rw-r--r-- | tests/testlinkedlist.c | 105 |
1 files changed, 30 insertions, 75 deletions
diff --git a/tests/testlinkedlist.c b/tests/testlinkedlist.c index a4113f3..399055b 100644 --- a/tests/testlinkedlist.c +++ b/tests/testlinkedlist.c @@ -65,6 +65,17 @@ typedef struct _ListTests ListTests; typedef struct _ListTestsClass ListTestsClass; typedef struct _ListTestsPrivate ListTestsPrivate; +#define TYPE_BIDIR_LIST_TESTS (bidir_list_tests_get_type ()) +#define BIDIR_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BIDIR_LIST_TESTS, BidirListTests)) +#define BIDIR_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BIDIR_LIST_TESTS, BidirListTestsClass)) +#define IS_BIDIR_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BIDIR_LIST_TESTS)) +#define IS_BIDIR_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BIDIR_LIST_TESTS)) +#define BIDIR_LIST_TESTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BIDIR_LIST_TESTS, BidirListTestsClass)) + +typedef struct _BidirListTests BidirListTests; +typedef struct _BidirListTestsClass BidirListTestsClass; +typedef struct _BidirListTestsPrivate BidirListTestsPrivate; + #define TYPE_LINKED_LIST_TESTS (linked_list_tests_get_type ()) #define LINKED_LIST_TESTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_LINKED_LIST_TESTS, LinkedListTests)) #define LINKED_LIST_TESTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_LINKED_LIST_TESTS, LinkedListTestsClass)) @@ -110,13 +121,22 @@ struct _ListTestsClass { void (*test_duplicates_are_retained) (ListTests* self); }; -struct _LinkedListTests { +struct _BidirListTests { ListTests parent_instance; + BidirListTestsPrivate * priv; +}; + +struct _BidirListTestsClass { + ListTestsClass parent_class; +}; + +struct _LinkedListTests { + BidirListTests parent_instance; LinkedListTestsPrivate * priv; }; struct _LinkedListTestsClass { - ListTestsClass parent_class; + BidirListTestsClass parent_class; }; typedef void (*GeeTestCaseTestMethod) (void* user_data); @@ -126,34 +146,21 @@ static gpointer linked_list_tests_parent_class = NULL; GType gee_test_case_get_type (void) G_GNUC_CONST; GType collection_tests_get_type (void) G_GNUC_CONST; GType list_tests_get_type (void) G_GNUC_CONST; +GType bidir_list_tests_get_type (void) G_GNUC_CONST; GType linked_list_tests_get_type (void) G_GNUC_CONST; enum { LINKED_LIST_TESTS_DUMMY_PROPERTY }; LinkedListTests* linked_list_tests_new (void); LinkedListTests* linked_list_tests_construct (GType object_type); -ListTests* list_tests_construct (GType object_type, const gchar* name); -void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target); -static void linked_list_tests_test_selected_functions (LinkedListTests* self); -static void _linked_list_tests_test_selected_functions_gee_test_case_test_method (gpointer self); -void linked_list_tests_test_gobject_properties (LinkedListTests* self); -static void _linked_list_tests_test_gobject_properties_gee_test_case_test_method (gpointer self); +BidirListTests* bidir_list_tests_construct (GType object_type, const gchar* name); +void gee_test_case_add_test (GeeTestCase* self, const gchar* name, GeeTestCaseTestMethod test, void* test_target, GDestroyNotify test_target_destroy_notify); static void linked_list_tests_test_sort (LinkedListTests* self); static void _linked_list_tests_test_sort_gee_test_case_test_method (gpointer self); static void linked_list_tests_real_set_up (GeeTestCase* base); static void linked_list_tests_real_tear_down (GeeTestCase* base); -static void _linked_list_tests_test_selected_functions_gee_test_case_test_method (gpointer self) { - linked_list_tests_test_selected_functions (self); -} - - -static void _linked_list_tests_test_gobject_properties_gee_test_case_test_method (gpointer self) { - linked_list_tests_test_gobject_properties (self); -} - - static void _linked_list_tests_test_sort_gee_test_case_test_method (gpointer self) { linked_list_tests_test_sort (self); } @@ -161,10 +168,8 @@ static void _linked_list_tests_test_sort_gee_test_case_test_method (gpointer sel LinkedListTests* linked_list_tests_construct (GType object_type) { LinkedListTests * self = NULL; - self = (LinkedListTests*) list_tests_construct (object_type, "LinkedList"); - gee_test_case_add_test ((GeeTestCase*) self, "[LinkedList] selected functions", _linked_list_tests_test_selected_functions_gee_test_case_test_method, self); - gee_test_case_add_test ((GeeTestCase*) self, "[LinkedList] GObject properties", _linked_list_tests_test_gobject_properties_gee_test_case_test_method, self); - gee_test_case_add_test ((GeeTestCase*) self, "[LinkedList] sort", _linked_list_tests_test_sort_gee_test_case_test_method, self); + self = (LinkedListTests*) bidir_list_tests_construct (object_type, "LinkedList"); + gee_test_case_add_test ((GeeTestCase*) self, "[LinkedList] sort", _linked_list_tests_test_sort_gee_test_case_test_method, g_object_ref (self), g_object_unref); return self; } @@ -178,7 +183,7 @@ static void linked_list_tests_real_set_up (GeeTestCase* base) { LinkedListTests * self; GeeLinkedList* _tmp0_; self = (LinkedListTests*) base; - _tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL); + _tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL); _g_object_unref0 (((CollectionTests*) self)->test_collection); ((CollectionTests*) self)->test_collection = (GeeCollection*) _tmp0_; } @@ -197,56 +202,6 @@ static gpointer _g_object_ref0 (gpointer self) { } -static void linked_list_tests_test_selected_functions (LinkedListTests* self) { - GeeCollection* _tmp0_; - GeeLinkedList* _tmp1_; - GeeLinkedList* test_list; - GEqualFunc _tmp2_; - GEqualFunc _tmp3_; - GEqualFunc _tmp4_; - g_return_if_fail (self != NULL); - _tmp0_ = ((CollectionTests*) self)->test_collection; - _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GEE_TYPE_LINKED_LIST) ? ((GeeLinkedList*) _tmp0_) : NULL); - test_list = _tmp1_; - _vala_assert (test_list != NULL, "test_list != null"); - _tmp2_ = gee_linked_list_get_equal_func (test_list); - _tmp3_ = _tmp2_; - _tmp4_ = g_str_equal; - _vala_assert (_tmp3_ == _tmp4_, "test_list.equal_func == str_equal"); - _g_object_unref0 (test_list); -} - - -void linked_list_tests_test_gobject_properties (LinkedListTests* self) { - GeeCollection* _tmp0_; - GeeLinkedList* _tmp1_; - GeeLinkedList* test_list; - GValue value = {0}; - GValue _tmp2_ = {0}; - GValue _tmp3_; - void* _tmp4_ = NULL; - GEqualFunc _tmp5_; - GEqualFunc _tmp6_; - g_return_if_fail (self != NULL); - _tmp0_ = ((CollectionTests*) self)->test_collection; - _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GEE_TYPE_LINKED_LIST) ? ((GeeLinkedList*) _tmp0_) : NULL); - test_list = _tmp1_; - _vala_assert (test_list != NULL, "test_list != null"); - g_value_init (&_tmp2_, G_TYPE_POINTER); - G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL; - value = _tmp2_; - _tmp3_ = value; - g_object_get_property ((GObject*) test_list, "equal-func", &value); - _tmp4_ = g_value_get_pointer (&value); - _tmp5_ = gee_linked_list_get_equal_func (test_list); - _tmp6_ = _tmp5_; - _vala_assert (_tmp4_ == ((void*) _tmp6_), "value.get_pointer () == (void*) test_list.equal_func"); - g_value_unset (&value); - G_IS_VALUE (&value) ? (g_value_unset (&value), NULL) : NULL; - _g_object_unref0 (test_list); -} - - static void linked_list_tests_test_sort (LinkedListTests* self) { GeeCollection* _tmp0_; GeeLinkedList* _tmp1_; @@ -292,7 +247,7 @@ static void linked_list_tests_test_sort (LinkedListTests* self) { gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "ten"); gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "eleven"); gee_abstract_collection_add ((GeeAbstractCollection*) test_list, "twelve"); - gee_list_sort ((GeeList*) test_list, NULL); + gee_list_sort ((GeeList*) test_list, NULL, NULL, NULL); _tmp2_ = gee_abstract_list_get ((GeeAbstractList*) test_list, 0); _tmp3_ = (gchar*) _tmp2_; _vala_assert (g_strcmp0 (_tmp3_, "eight") == 0, "test_list.get (0) == \"eight\""); @@ -361,7 +316,7 @@ GType linked_list_tests_get_type (void) { if (g_once_init_enter (&linked_list_tests_type_id__volatile)) { static const GTypeInfo g_define_type_info = { sizeof (LinkedListTestsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) linked_list_tests_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LinkedListTests), 0, (GInstanceInitFunc) linked_list_tests_instance_init, NULL }; GType linked_list_tests_type_id; - linked_list_tests_type_id = g_type_register_static (TYPE_LIST_TESTS, "LinkedListTests", &g_define_type_info, 0); + linked_list_tests_type_id = g_type_register_static (TYPE_BIDIR_LIST_TESTS, "LinkedListTests", &g_define_type_info, 0); g_once_init_leave (&linked_list_tests_type_id__volatile, linked_list_tests_type_id); } return linked_list_tests_type_id__volatile; |