[gtksourceview/wip/search: 21/36] search: unit test for multiple lines
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/search: 21/36] search: unit test for multiple lines
- Date: Sat, 6 Jul 2013 15:58:29 +0000 (UTC)
commit d32c690aa1990eebad685cfc923489a33337746c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Jul 2 12:51:16 2013 +0200
search: unit test for multiple lines
tests/test-search.c | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/tests/test-search.c b/tests/test-search.c
index fe25417..3e725e5 100644
--- a/tests/test-search.c
+++ b/tests/test-search.c
@@ -224,6 +224,33 @@ test_occurrences_count_with_delete (void)
g_object_unref (source_buffer);
}
+static void
+test_occurrences_count_multiple_lines (void)
+{
+ GtkSourceBuffer *source_buffer = gtk_source_buffer_new (NULL);
+ GtkTextBuffer *text_buffer = GTK_TEXT_BUFFER (source_buffer);
+ guint occurrences_count;
+
+ gtk_source_buffer_set_search_text (source_buffer, "world\nhello");
+
+ gtk_text_buffer_set_text (text_buffer, "hello world\nhello world\nhello world\n", -1);
+ flush_queue ();
+ occurrences_count = gtk_source_buffer_get_search_occurrences_count (source_buffer);
+ g_assert_cmpuint (occurrences_count, ==, 2);
+
+ gtk_source_buffer_set_search_text (source_buffer, "world\n");
+ flush_queue ();
+ occurrences_count = gtk_source_buffer_get_search_occurrences_count (source_buffer);
+ g_assert_cmpuint (occurrences_count, ==, 3);
+
+ gtk_source_buffer_set_search_text (source_buffer, "\nhello world\n");
+ flush_queue ();
+ occurrences_count = gtk_source_buffer_get_search_occurrences_count (source_buffer);
+ g_assert_cmpuint (occurrences_count, ==, 1);
+
+ g_object_unref (source_buffer);
+}
+
int
main (int argc, char **argv)
{
@@ -232,6 +259,7 @@ main (int argc, char **argv)
g_test_add_func ("/Search/occurrences-count/simple", test_occurrences_count_simple);
g_test_add_func ("/Search/occurrences-count/with-insert", test_occurrences_count_with_insert);
g_test_add_func ("/Search/occurrences-count/with-delete", test_occurrences_count_with_delete);
+ g_test_add_func ("/Search/occurrences-count/multiple-lines", test_occurrences_count_multiple_lines);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]