[gtksourceview/wip/regex-search] test-search: test occurrence position
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/regex-search] test-search: test occurrence position
- Date: Tue, 23 Jul 2013 11:24:14 +0000 (UTC)
commit 7e8d3e33ed42c29f8bbcc2b683fe38ad85a974d8
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Jul 22 14:28:31 2013 +0200
test-search: test occurrence position
tests/test-search.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-search.c b/tests/test-search.c
index 03b7bdb..ff6e7f3 100644
--- a/tests/test-search.c
+++ b/tests/test-search.c
@@ -703,6 +703,39 @@ test_get_search_text (void)
g_object_unref (source_buffer);
}
+static void
+test_occurrence_position (void)
+{
+ GtkSourceBuffer *source_buffer = gtk_source_buffer_new (NULL);
+ GtkTextBuffer *text_buffer = GTK_TEXT_BUFFER (source_buffer);
+ GtkTextIter start;
+ GtkTextIter end;
+ gint pos;
+
+ gtk_text_buffer_set_text (text_buffer, "aaaa", -1);
+ gtk_source_buffer_set_search_text (source_buffer, "aa");
+ flush_queue ();
+
+ gtk_text_buffer_get_start_iter (text_buffer, &start);
+ end = start;
+ gtk_text_iter_forward_chars (&end, 2);
+
+ pos = gtk_source_buffer_get_search_occurrence_position (source_buffer, &start, &end);
+ g_assert_cmpint (pos, ==, 1);
+
+ gtk_text_iter_forward_char (&start);
+ gtk_text_iter_forward_char (&end);
+ pos = gtk_source_buffer_get_search_occurrence_position (source_buffer, &start, &end);
+ g_assert_cmpint (pos, ==, 0);
+
+ gtk_text_iter_forward_char (&start);
+ gtk_text_iter_forward_char (&end);
+ pos = gtk_source_buffer_get_search_occurrence_position (source_buffer, &start, &end);
+ g_assert_cmpint (pos, ==, 2);
+
+ g_object_unref (source_buffer);
+}
+
int
main (int argc, char **argv)
{
@@ -722,6 +755,7 @@ main (int argc, char **argv)
g_test_add_func ("/Search/backward/subprocess/async-wrap-around",
test_async_backward_search_wrap_around);
g_test_add_func ("/Search/highlight", test_highlight);
g_test_add_func ("/Search/get-search-text", test_get_search_text);
+ g_test_add_func ("/Search/occurrence-position", test_occurrence_position);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]