[gtksourceview] SearchContext: Add test case for insertion on word boundaries



commit 86991baebf0d69601580db351dfd2ba387a84a05
Author: Matthew Leeds <mleeds redhat com>
Date:   Thu Jun 23 10:05:39 2016 -0400

    SearchContext: Add test case for insertion on word boundaries
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767978

 testsuite/test-search-context.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/testsuite/test-search-context.c b/testsuite/test-search-context.c
index fd7586e..9c8e717 100644
--- a/testsuite/test-search-context.c
+++ b/testsuite/test-search-context.c
@@ -367,6 +367,7 @@ test_search_at_word_boundaries (void)
        GtkTextBuffer *text_buffer = GTK_TEXT_BUFFER (source_buffer);
        GtkSourceSearchSettings *settings = gtk_source_search_settings_new ();
        GtkSourceSearchContext *context = gtk_source_search_context_new (source_buffer, settings);
+       GtkTextIter iter;
        gboolean at_word_boundaries;
        gint occurrences_count;
 
@@ -381,13 +382,27 @@ test_search_at_word_boundaries (void)
        occurrences_count = gtk_source_search_context_get_occurrences_count (context);
        g_assert_cmpint (occurrences_count, ==, 1);
 
+       /* Contents: "AtWordBoundaries AtWord AtWord" */
+       gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 16);
+       gtk_text_buffer_insert (text_buffer, &iter, " AtWord", -1);
+       flush_queue ();
+       occurrences_count = gtk_source_search_context_get_occurrences_count (context);
+       g_assert_cmpint (occurrences_count, ==, 2);
+
+       /* Contents: "AtWordBoundaries AtWordd AtWord" */
+       gtk_text_buffer_get_iter_at_offset (text_buffer, &iter, 23);
+       gtk_text_buffer_insert (text_buffer, &iter, "d", -1);
+       flush_queue ();
+       occurrences_count = gtk_source_search_context_get_occurrences_count (context);
+       g_assert_cmpint (occurrences_count, ==, 1);
+
        gtk_source_search_settings_set_at_word_boundaries (settings, FALSE);
        at_word_boundaries = gtk_source_search_settings_get_at_word_boundaries (settings);
        g_assert (!at_word_boundaries);
 
        flush_queue ();
        occurrences_count = gtk_source_search_context_get_occurrences_count (context);
-       g_assert_cmpint (occurrences_count, ==, 2);
+       g_assert_cmpint (occurrences_count, ==, 3);
 
        /* Word with underscores */
 


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