summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSébastien Wilmet <swilmet@gnome.org>2015-11-26 13:31:19 +0100
committerSébastien Wilmet <swilmet@gnome.org>2015-11-30 19:46:16 +0100
commit1a8f3e2462829f8a186590a6ad6b7642309baa5b (patch)
tree7fb64ae5d767b38adad0c4cda2e03c819e29d4e2 /testsuite
parent0a35886b0a39a57b819d1f51adb357c13bda5bf3 (diff)
downloadgtk+-1a8f3e2462829f8a186590a6ad6b7642309baa5b.tar.gz
textiter: fix bug in case insensitive backward search
'win.lines' contains the same content as the GtkTextBuffer, so to find @match_start, forward_chars_with_skipping() is called with skip_decomp=FALSE (the last parameter). So far so good. On the other hand, the content 'lines' (the needle split in lines) is casefolded and normalized for a case insensitive search. So, forward_chars_with_skipping(..., skip_decomp=TRUE) must be called only for the portion of text containing the needle. Since 'start_tmp' contains the location at the start of the match, we can simply begin at that location to find the end of the match. Unit tests are added. https://bugzilla.gnome.org/show_bug.cgi?id=758698
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/textiter.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/gtk/textiter.c b/testsuite/gtk/textiter.c
index d05a8972de..51c209b5c6 100644
--- a/testsuite/gtk/textiter.c
+++ b/testsuite/gtk/textiter.c
@@ -186,6 +186,12 @@ test_search (void)
check_found_backward ("This is some \303\240 text", "some \303\240", 0, 8, 14, "some \303\240");
check_found_backward ("This is some \303\240 text", "\303\240 text", 0, 13, 19, "\303\240 text");
check_found_backward ("This is some \303\240 text", "some \303\240 text", 0, 8, 19, "some \303\240 text");
+
+ /* multi-byte characters outside the needle */
+ check_found_forward ("\303\200 aa", "aa", 0, 2, 4, "aa");
+ check_found_forward ("aa \303\200", "aa", 0, 0, 2, "aa");
+ check_found_backward ("\303\200 aa", "aa", 0, 2, 4, "aa");
+ check_found_backward ("aa \303\200", "aa", 0, 0, 2, "aa");
}
static void
@@ -265,6 +271,12 @@ test_search_caseless (void)
check_found_backward ("This is some Foo\nFoo text", "foo\nfoo", flags, 13, 20, "Foo\nFoo");
check_found_backward ("This is some \303\200\n\303\200 text", "\303\240\n\303\240", flags, 13, 16, "\303\200\n\303\200");
check_found_backward ("This is some \303\200\n\303\200 text", "a\314\200\na\314\200", flags, 13, 16, "\303\200\n\303\200");
+
+ /* multi-byte characters outside the needle */
+ check_found_forward ("\303\200 aa", "aa", flags, 2, 4, "aa");
+ check_found_forward ("aa \303\200", "aa", flags, 0, 2, "aa");
+ check_found_backward ("\303\200 aa", "aa", flags, 2, 4, "aa");
+ check_found_backward ("aa \303\200", "aa", flags, 0, 2, "aa");
}
static void