[anjuta] libanjuta: Add basic tests for AnjutaCompletion
- From: Carl-Anton Ingmarsson <carlantoni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] libanjuta: Add basic tests for AnjutaCompletion
- Date: Mon, 18 Feb 2013 19:21:46 +0000 (UTC)
commit 9c9d4ccab522f0539966af045b9fffd1f8d5bfa2
Author: Carl-Anton Ingmarsson <ca ingmarsson gmail com>
Date: Sun Feb 17 22:25:44 2013 +0100
libanjuta: Add basic tests for AnjutaCompletion
https://bugzilla.gnome.org/show_bug.cgi?id=694048
libanjuta/tests/Makefile.am | 10 +++-
libanjuta/tests/anjuta-completion-test.c | 85 ++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+), 2 deletions(-)
---
diff --git a/libanjuta/tests/Makefile.am b/libanjuta/tests/Makefile.am
index fb78a73..2473355 100644
--- a/libanjuta/tests/Makefile.am
+++ b/libanjuta/tests/Makefile.am
@@ -1,5 +1,7 @@
-noinst_PROGRAMS = anjuta-tabber-test \
- anjuta-token-test
+noinst_PROGRAMS = \
+ anjuta-completion-test \
+ anjuta-tabber-test \
+ anjuta-token-test
# Include paths
AM_CPPFLAGS = \
@@ -8,6 +10,10 @@ AM_CPPFLAGS = \
$(GDA_CFLAGS) \
$(LIBANJUTA_CFLAGS)
+anjuta_completion_test_CFLAGS = $(LIBANJUTA_CFLAGS)
+anjuta_completion_test_LDADD = $(LIBANJUTA_LIBS)
+anjuta_completion_test_SOURCES = anjuta-completion-test.c
+
anjuta_tabber_test_CFLAGS = $(LIBANJUTA_CFLAGS)
anjuta_tabber_test_LDADD = $(LIBANJUTA_LIBS) $(ANJUTA_LIBS)
diff --git a/libanjuta/tests/anjuta-completion-test.c b/libanjuta/tests/anjuta-completion-test.c
new file mode 100644
index 0000000..91b60aa
--- /dev/null
+++ b/libanjuta/tests/anjuta-completion-test.c
@@ -0,0 +1,85 @@
+/*
+ * anjuta-completion-test.c
+ *
+ * Copyright (C) 2013 - Carl-Anton Ingmarsson
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libanjuta/anjuta-completion.h>
+
+static void
+test_completion_basic (void)
+{
+ AnjutaCompletion* completion;
+ GList* l;
+
+ completion = anjuta_completion_new (NULL);
+ anjuta_completion_add_item (completion, "a_a");
+ anjuta_completion_add_item (completion, "a_b");
+ anjuta_completion_add_item (completion, "a_c");
+ anjuta_completion_add_item (completion, "a_d");
+
+ /* Match everything */
+ l = anjuta_completion_complete (completion, "a", -1);
+ g_assert_cmpint (g_list_length (l), ==, 4);
+ g_list_free (l);
+
+ /* Match everything again */
+ l = anjuta_completion_complete (completion, "a", -1);
+ g_assert_cmpint (g_list_length (l), ==, 4);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "b", -1);
+ g_assert_cmpint (g_list_length (l), ==, 0);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "a_", -1);
+ g_assert_cmpint (g_list_length (l), ==, 4);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "a_a", -1);
+ g_assert_cmpint (g_list_length (l), ==, 1);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "a_d", -1);
+ g_assert_cmpint (g_list_length (l), ==, 1);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "a_e", -1);
+ g_assert_cmpint (g_list_length (l), ==, 0);
+ g_list_free (l);
+
+
+ /* Test limiting the number of completions */
+ l = anjuta_completion_complete (completion, "a_", 1);
+ g_assert_cmpint (g_list_length (l), ==, 1);
+ g_list_free (l);
+
+ l = anjuta_completion_complete (completion, "a_", 3);
+ g_assert_cmpint (g_list_length (l), ==, 3);
+ g_list_free (l);
+
+ g_object_unref (completion);
+}
+
+int
+main (int argc, char** argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/completion/basic", test_completion_basic);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]