[gtksourceview/wip/marks-sequence] Add unit tests for the MarksSequence



commit 7432a419d33c583c61a65098287b386eca2af122
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Sep 8 20:02:29 2013 +0200

    Add unit tests for the MarksSequence

 tests/Makefile.am           |    7 ++++
 tests/test-marks-sequence.c |   72 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b5e6827..0dbcc93 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -102,6 +102,13 @@ test_mark_LDADD =          \
        $(DEP_LIBS)                     \
        $(TESTS_LIBS)
 
+UNIT_TEST_PROGS += test-marks-sequence
+test_marks_sequence_SOURCES = test-marks-sequence.c
+test_marks_sequence_LDADD =                                            \
+       $(top_builddir)/gtksourceview/libgtksourceview-private.la       \
+       $(DEP_LIBS)                                                     \
+       $(TESTS_LIBS)
+
 UNIT_TEST_PROGS += test-printcompositor
 test_printcompositor_SOURCES =         \
        test-printcompositor.c
diff --git a/tests/test-marks-sequence.c b/tests/test-marks-sequence.c
new file mode 100644
index 0000000..de27d6d
--- /dev/null
+++ b/tests/test-marks-sequence.c
@@ -0,0 +1,72 @@
+/*
+ * test-marks-sequence.c
+ * This file is part of GtkSourceView
+ *
+ * Copyright (C) 2013 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * GtkSourceView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GtkSourceView 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <gtk/gtk.h>
+#include "gtksourceview/gtksourcemarkssequence.h"
+
+static void
+test_simple (void)
+{
+       GtkTextBuffer *buffer = gtk_text_buffer_new (NULL);
+       GtkSourceMarksSequence *seq = _gtk_source_marks_sequence_new (buffer);
+       GtkTextIter iter;
+       GtkTextMark *mark1;
+       GtkTextMark *mark2;
+       GtkTextMark *mark;
+
+       gtk_text_buffer_set_text (buffer, "text", -1);
+
+       gtk_text_buffer_get_start_iter (buffer, &iter);
+       mark1 = gtk_text_buffer_create_mark (buffer, NULL, &iter, TRUE);
+
+       gtk_text_buffer_get_end_iter (buffer, &iter);
+       mark2 = gtk_text_buffer_create_mark (buffer, NULL, &iter, TRUE);
+
+       _gtk_source_marks_sequence_add (seq, mark1);
+       _gtk_source_marks_sequence_add (seq, mark2);
+
+       mark = _gtk_source_marks_sequence_next (seq, mark1);
+       g_assert (mark == mark2);
+
+       mark = _gtk_source_marks_sequence_next (seq, mark2);
+       g_assert (mark == NULL);
+
+       mark = _gtk_source_marks_sequence_prev (seq, mark2);
+       g_assert (mark == mark1);
+
+       mark = _gtk_source_marks_sequence_prev (seq, mark1);
+       g_assert (mark == NULL);
+
+       _gtk_source_marks_sequence_remove (seq, mark2);
+
+       g_object_unref (buffer);
+       g_object_unref (seq);
+}
+
+int
+main (int argc, char **argv)
+{
+       gtk_test_init (&argc, &argv);
+
+       g_test_add_func ("/MarksSequence/simple", test_simple);
+
+       return g_test_run ();
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]