[gnome-text-editor] tests: add additional spell cursor test



commit c13fa20e46be330c0f46c1144c2811f4fd89b999
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 10 17:18:08 2021 -0700

    tests: add additional spell cursor test

 src/test-spell-cursor.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/src/test-spell-cursor.c b/src/test-spell-cursor.c
index e729d73..b6f5b33 100644
--- a/src/test-spell-cursor.c
+++ b/src/test-spell-cursor.c
@@ -49,11 +49,41 @@ test_cursor (void)
   _cjh_text_region_free (region);
 }
 
+static void
+test_cursor_in_word (void)
+{
+  g_autoptr(GtkTextBuffer) buffer = gtk_text_buffer_new (NULL);
+  CjhTextRegion *region = _cjh_text_region_new (NULL, NULL);
+  g_autoptr(EditorSpellCursor) cursor = editor_spell_cursor_new (buffer, region, NULL);
+  const char *pos = strstr (test_text, "ries "); /* se|ries */
+  gsize offset = pos - test_text;
+  char *word;
+
+  gtk_text_buffer_set_text (buffer, test_text, -1);
+  _cjh_text_region_insert (region, 0, strlen (test_text), GINT_TO_POINTER (1));
+  _cjh_text_region_replace (region, offset, strlen (test_text) - offset, NULL);
+
+  word = next_word (cursor);
+  g_assert_cmpstr (word, ==, "series");
+
+  word = next_word (cursor);
+  g_assert_cmpstr (word, ==, "of");
+
+  word = next_word (cursor);
+  g_assert_cmpstr (word, ==, "words");
+
+  word = next_word (cursor);
+  g_assert_cmpstr (word, ==, NULL);
+
+  _cjh_text_region_free (region);
+}
+
 int
 main (int argc,
       char *argv[])
 {
   g_test_init (&argc, &argv, NULL);
   g_test_add_func ("/Spelling/Cursor/basic", test_cursor);
+  g_test_add_func ("/Spelling/Cursor/in_word", test_cursor_in_word);
   return g_test_run ();
 }


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