[gspell] testsuite: add unit test for GspellChecker
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gspell] testsuite: add unit test for GspellChecker
- Date: Thu, 4 Feb 2016 11:13:18 +0000 (UTC)
commit c1bee60ed24a18306a734a69d7244fb3d8d3dca5
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Feb 1 15:33:39 2016 +0100
testsuite: add unit test for GspellChecker
Makefile.am | 2 +-
configure.ac | 1 +
testsuite/Makefile.am | 18 +++++++++++++++
testsuite/test-checker.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 73 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 313aa9f..a998a5b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gspell po docs tests
+SUBDIRS = gspell po docs tests testsuite
pkgconfig_DATA = gspell-1.pc
diff --git a/configure.ac b/configure.ac
index 2a79e16..b10fa53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,7 @@ AC_CONFIG_FILES([
gspell/resources/Makefile
po/Makefile.in
tests/Makefile
+ testsuite/Makefile
])
AC_OUTPUT
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
new file mode 100644
index 0000000..17cdcfb
--- /dev/null
+++ b/testsuite/Makefile.am
@@ -0,0 +1,18 @@
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ $(WARN_CFLAGS) \
+ $(DEP_CFLAGS)
+
+AM_LDFLAGS = $(WARN_LDFLAGS)
+
+LDADD = $(top_builddir)/gspell/libgspell-1.la \
+ $(DEP_LIBS)
+
+noinst_PROGRAMS = $(UNIT_TEST_PROGS)
+TESTS = $(UNIT_TEST_PROGS)
+UNIT_TEST_PROGS =
+
+UNIT_TEST_PROGS += test-checker
+test_checker_SOURCES = test-checker.c
+
+-include $(top_srcdir)/git.mk
diff --git a/testsuite/test-checker.c b/testsuite/test-checker.c
new file mode 100644
index 0000000..e859fe0
--- /dev/null
+++ b/testsuite/test-checker.c
@@ -0,0 +1,53 @@
+/*
+ * 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>
+
+static void
+test_check_word (void)
+{
+ const GspellLanguage *lang;
+ GspellChecker *checker;
+ gboolean correctly_spelled;
+ GError *error = NULL;
+
+ lang = gspell_language_lookup ("en_US");
+ g_assert (lang != NULL);
+
+ checker = gspell_checker_new (lang);
+
+ correctly_spelled = gspell_checker_check_word (checker, "hello", -1, &error);
+ g_assert_no_error (error);
+ g_assert_true (correctly_spelled);
+
+ correctly_spelled = gspell_checker_check_word (checker, "tkbqzat", -1, &error);
+ g_assert_no_error (error);
+ g_assert_false (correctly_spelled);
+}
+
+gint
+main (gint argc,
+ gchar **argv)
+{
+ gtk_test_init (&argc, &argv);
+
+ g_test_add_func ("/checker/check_word", test_check_word);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]