[gtksourceview] test-completion-model: get_providers()
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] test-completion-model: get_providers()
- Date: Fri, 11 Jan 2013 12:39:59 +0000 (UTC)
commit e27787bb532ac496adf12178a0cb1ebf049eb76c
Author: SÃbastien Wilmet <swilmet gnome org>
Date: Wed Jan 9 18:27:23 2013 +0100
test-completion-model: get_providers()
tests/test-completion-model.c | 50 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-completion-model.c b/tests/test-completion-model.c
index a2b2d4e..3431586 100644
--- a/tests/test-completion-model.c
+++ b/tests/test-completion-model.c
@@ -276,6 +276,31 @@ check_all_providers_with_and_without_headers (GtkSourceCompletionModel *model,
check_all_providers (model, all_providers, all_list_proposals, FALSE);
}
+static gboolean
+same_list_contents (GList *list1, GList *list2)
+{
+ GList *cur_item1 = list1;
+ GList *cur_item2 = list2;
+
+ if (g_list_length (list1) != g_list_length (list2))
+ {
+ return FALSE;
+ }
+
+ while (cur_item1 != NULL)
+ {
+ if (cur_item1->data != cur_item2->data)
+ {
+ return FALSE;
+ }
+
+ cur_item1 = g_list_next (cur_item1);
+ cur_item2 = g_list_next (cur_item2);
+ }
+
+ return TRUE;
+}
+
/* Tests */
static void
@@ -581,6 +606,28 @@ test_populate_several_batches (void)
g_list_free_full (all_proposals, g_object_unref);
}
+static void
+test_get_providers (void)
+{
+ GtkSourceCompletionModel *model = gtk_source_completion_model_new ();
+ GList *all_providers = NULL;
+ GList *all_list_proposals = NULL;
+ GList *providers_get = NULL;
+
+ /* Empty */
+ g_assert (gtk_source_completion_model_get_providers (model) == NULL);
+
+ /* Non-empty */
+ create_providers (&all_providers, &all_list_proposals);
+ populate_model (model, all_providers, all_list_proposals);
+
+ providers_get = gtk_source_completion_model_get_providers (model);
+ g_assert (same_list_contents (all_providers, providers_get));
+
+ g_object_unref (model);
+ free_providers (all_providers, all_list_proposals);
+}
+
int
main (int argc, char **argv)
{
@@ -612,5 +659,8 @@ main (int argc, char **argv)
g_test_add_func ("/CompletionModel/populate-several-batches",
test_populate_several_batches);
+ g_test_add_func ("/CompletionModel/get-providers",
+ test_get_providers);
+
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]