[gspell/wip/unit-tests: 5/5] testsuite: add unit tests for the InlineCheckerTextBuffer
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell/wip/unit-tests: 5/5] testsuite: add unit tests for the InlineCheckerTextBuffer
- Date: Thu, 4 Feb 2016 14:30:25 +0000 (UTC)
commit a8e3e68747bcb41ecfa6606d137595d2f87f6704
Author: Sébastien Wilmet <swilmet gnome org>
Date: Thu Feb 4 15:12:03 2016 +0100
testsuite: add unit tests for the InlineCheckerTextBuffer
testsuite/Makefile.am | 3 +
testsuite/test-inline-checker-text-buffer.c | 66 +++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index d22a7eb..88b31c7 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -15,4 +15,7 @@ UNIT_TEST_PROGS =
UNIT_TEST_PROGS += test-checker
test_checker_SOURCES = test-checker.c
+UNIT_TEST_PROGS += test-inline-checker-text-buffer
+test_inline_checker_text_buffer_SOURCES = test-inline-checker-text-buffer.c
+
-include $(top_srcdir)/git.mk
diff --git a/testsuite/test-inline-checker-text-buffer.c b/testsuite/test-inline-checker-text-buffer.c
new file mode 100644
index 0000000..128fce0
--- /dev/null
+++ b/testsuite/test-inline-checker-text-buffer.c
@@ -0,0 +1,66 @@
+/*
+ * This file is part of gspell, a spell-checking library.
+ *
+ * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ *
+ * This library 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.
+ *
+ * This library 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gspell/gspell.h>
+#include "gspell/gspell-inline-checker-text-buffer.h"
+
+static GtkTextBuffer *
+create_buffer (void)
+{
+ GtkTextBuffer *buffer;
+ const GspellLanguage *lang;
+ GspellChecker *checker;
+
+ buffer = gtk_text_buffer_new (NULL);
+
+ lang = gspell_language_lookup ("en_US");
+ checker = gspell_checker_new (lang);
+ gspell_text_buffer_set_spell_checker (buffer, checker);
+ g_object_unref (checker);
+
+ return buffer;
+}
+
+static void
+test_whole_buffer (void)
+{
+ GtkTextBuffer *buffer;
+ GspellInlineCheckerTextBuffer *inline_checker;
+
+ buffer = create_buffer ();
+ gtk_text_buffer_set_text (buffer, "hello jlyxdt", -1);
+
+ inline_checker = _gspell_inline_checker_text_buffer_new (buffer);
+ _gspell_inline_checker_text_buffer_set_unit_test_mode (inline_checker, TRUE);
+
+ g_object_unref (inline_checker);
+ g_object_unref (buffer);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gtk_test_init (&argc, &argv);
+
+ g_test_add_func ("/inline-checker-text-buffer/whole-buffer",
+ test_whole_buffer);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]