[gtksourceview/wip/chergert/vim] cleanup tests
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] cleanup tests
- Date: Fri, 5 Nov 2021 19:05:17 +0000 (UTC)
commit af06009b09fae618af443a19b07bf7c66c210470
Author: Christian Hergert <chergert redhat com>
Date: Fri Nov 5 12:05:12 2021 -0700
cleanup tests
testsuite/test-vim-text-object.c | 177 ++++++++++++++++++++-------------------
1 file changed, 91 insertions(+), 86 deletions(-)
---
diff --git a/testsuite/test-vim-text-object.c b/testsuite/test-vim-text-object.c
index 4315c244..b958123e 100644
--- a/testsuite/test-vim-text-object.c
+++ b/testsuite/test-vim-text-object.c
@@ -27,9 +27,8 @@
static void
run_test (GtkSourceVimState *text_object,
const char *text,
- guint position,
- const char *expect_selection,
- gboolean expect_fail)
+ guint position,
+ const char *expect_selection)
{
GtkSourceBuffer *buffer;
GtkTextIter begin, end;
@@ -45,13 +44,13 @@ run_test (GtkSourceVimState *text_object,
if (!gtk_source_vim_text_object_select (GTK_SOURCE_VIM_TEXT_OBJECT (text_object), &begin, &end))
{
- if (expect_fail)
+ if (expect_selection == NULL)
goto cleanup;
g_error ("Failed to select text-object\n\n'''%s'''\npotiion: %u\nepxecting: '''%s'''",
text, position, expect_selection);
}
- if (expect_fail)
+ if (expect_selection == NULL)
{
char *out = gtk_text_iter_get_slice (&begin, &end);
g_error ("Expected to fail selection but got '''%s'''", out);
@@ -72,107 +71,113 @@ cleanup:
static void
test_word (void)
{
- run_test (gtk_source_vim_text_object_new_inner_word (), "", 0, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "this is some- text to modify\n", 8, "some",
FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "something here\n", 10, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "something here", 9, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "a", 0, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "a b", 1, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "+ -", 1, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "z a", 2, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_a_word (), "a b", 1, " b", FALSE);
- run_test (gtk_source_vim_text_object_new_a_word (), "+ -", 1, " -", FALSE);
- run_test (gtk_source_vim_text_object_new_a_word (), "a b", 2, "b", FALSE);
- run_test (gtk_source_vim_text_object_new_a_word (), "a b c", 2, "b ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_word (), "\n \n\n", 2, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_a_word (), "\n \n\n", 2, " ", FALSE);
+ run_test (gtk_source_vim_text_object_new_inner_word (), "", 0, "");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "this is some- text to modify\n", 8, "some");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "something here\n", 10, " ");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "something here", 9, " ");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "a", 0, "a");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "a b", 1, " ");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "+ -", 1, " ");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "z a", 2, "a");
+ run_test (gtk_source_vim_text_object_new_a_word (), "a b", 1, " b");
+ run_test (gtk_source_vim_text_object_new_a_word (), "+ -", 1, " -");
+ run_test (gtk_source_vim_text_object_new_a_word (), "a b", 2, "b");
+ run_test (gtk_source_vim_text_object_new_a_word (), "a b c", 2, "b ");
+ run_test (gtk_source_vim_text_object_new_inner_word (), "\n \n\n", 2, " ");
+ run_test (gtk_source_vim_text_object_new_a_word (), "\n \n\n", 2, " ");
}
static void
test_WORD (void)
{
- run_test (gtk_source_vim_text_object_new_inner_WORD (), "this is some- text to modify\n", 8, "some-",
FALSE);
- run_test (gtk_source_vim_text_object_new_inner_WORD (), "something here\n", 10, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_WORD (), "something here", 9, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_WORD (), "\n \n\n", 2, " ", FALSE);
- run_test (gtk_source_vim_text_object_new_a_WORD (), "\n \n\n", 2, " ", FALSE);
+ run_test (gtk_source_vim_text_object_new_inner_WORD (), "this is some- text to modify\n", 8, "some-");
+ run_test (gtk_source_vim_text_object_new_inner_WORD (), "something here\n", 10, " ");
+ run_test (gtk_source_vim_text_object_new_inner_WORD (), "something here", 9, " ");
+ run_test (gtk_source_vim_text_object_new_inner_WORD (), "\n \n\n", 2, " ");
+ run_test (gtk_source_vim_text_object_new_a_WORD (), "\n \n\n", 2, " ");
}
static void
test_block (void)
{
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "this_is_a_function (some stuff\n and
some more)\ntrailing", 23, "(some stuff\n and some more)", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "this_is_a_function (some stuff\n and
some more)\ntrailing", 23, "some stuff\n and some more", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(should not match\n", 5, NULL, TRUE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 0, "m", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 1, "m", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 2, "m", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 3, NULL, TRUE);
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 0, "(m)", FALSE);
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 1, "(m)", FALSE);
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 2, "(m)", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 3, NULL, TRUE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 2, NULL, TRUE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 1, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 0, "", FALSE);
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "() ", 1, "()", FALSE);
- run_test (gtk_source_vim_text_object_new_a_block_paren (), "() ", 0, "()", FALSE);
- run_test (gtk_source_vim_text_object_new_a_block_lt_gt (), "<a></a>", 0, "<a>", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a>", 0, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a>", 2, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 0, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 1, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 2, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 3, "/a", FALSE);
-
- run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 0, "a[b[c]]", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 4, "c", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 5, "c", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 6, "c", FALSE);
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "this_is_a_function (some stuff\n and
some more)\ntrailing", 23, "(some stuff\n and some more)");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "this_is_a_function (some stuff\n and
some more)\ntrailing", 23, "some stuff\n and some more");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(should not match\n", 5, NULL);
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 0, "m");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 1, "m");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 2, "m");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 3, NULL);
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 0, "(m)");
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 1, "(m)");
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "(m)", 2, "(m)");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "(m)", 3, NULL);
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 2, NULL);
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 1, "");
+ run_test (gtk_source_vim_text_object_new_inner_block_paren (), "()", 0, "");
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "() ", 1, "()");
+ run_test (gtk_source_vim_text_object_new_a_block_paren (), "() ", 0, "()");
+ run_test (gtk_source_vim_text_object_new_a_block_lt_gt (), "<a></a>", 0, "<a>");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a>", 0, "a");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a>", 2, "a");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 0, "a");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 1, "a");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 2, "a");
+ run_test (gtk_source_vim_text_object_new_inner_block_lt_gt (), "<a></a>", 3, "/a");
+
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 0, "a[b[c]]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 1, "a[b[c]]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 2, "b[c]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 3, "b[c]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 4, "c");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 5, "c");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 6, "c");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 7, "b[c]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 8, "a[b[c]]");
+ run_test (gtk_source_vim_text_object_new_inner_block_bracket (), "[a[b[c]]]", 9, NULL);
}
static void
test_quote (void)
{
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this is a string.\"", 0, "this is
a string.", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"this is a string.\"", 0, "\"this is a
string.\"", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this is a string.\n", 0, NULL,
TRUE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.\"", 6, "this
", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"this \"is a string.\"", 6, "\"this
\"", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.\"", 7, "is a
string.", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.", 7, NULL,
TRUE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\"", 0, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\"", 1, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), " \"\"", 2, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\" ", 1, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\" \"", 1, "", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"a\" \"", 1, "a", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\"", 0, "\"\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\"", 1, "\"\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), " \"\"", 2, "\"\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\" ", 1, "\"\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\" \"", 1, "\"\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"a\"b\"", 2, "\"a\"", FALSE);
- run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"a\"b\"", 3, "\"b\"", FALSE);
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this is a string.\"", 0, "this is
a string.");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"this is a string.\"", 0, "\"this is a
string.\"");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this is a string.\n", 0, NULL);
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.\"", 6, "this
");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"this \"is a string.\"", 6, "\"this
\"");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.\"", 7, "is a
string.");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"this \"is a string.", 7, NULL);
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\"", 0, "");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\"", 1, "");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), " \"\"", 2, "");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\" ", 1, "");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"\" \"", 1, "");
+ run_test (gtk_source_vim_text_object_new_inner_quote_double (), "\"a\" \"", 1, "a");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\"", 0, "\"\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\"", 1, "\"\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), " \"\"", 2, "\"\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\" ", 1, "\"\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"\" \"", 1, "\"\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"a\"b\"", 2, "\"a\"");
+ run_test (gtk_source_vim_text_object_new_a_quote_double (), "\"a\"b\"", 3, "\"b\"");
}
static void
test_sentence (void)
{
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 0, "a.", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 1, "a.", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 2, "b!", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 3, "b!", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 4, "b!", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 5, "c?", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 6, "c?", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "\n a. b! c?", 1, "a.", FALSE);
- run_test (gtk_source_vim_text_object_new_inner_sentence (), "\n a. b! c?", 2, "a.", FALSE);
-
- run_test (gtk_source_vim_text_object_new_a_sentence (), "a. b! c?", 0, "a. ", FALSE);
- run_test (gtk_source_vim_text_object_new_a_sentence (), " a. b! c?", 0, " a. ", FALSE);
- run_test (gtk_source_vim_text_object_new_a_sentence (), "\n a. b! c?", 1, "a. ", FALSE);
- run_test (gtk_source_vim_text_object_new_a_sentence (), "\n a. b! c?", 2, "a. ", FALSE);
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 0, "a.");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 1, "a.");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 2, "b!");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 3, "b!");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 4, "b!");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 5, "c?");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "a. b! c?", 6, "c?");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "\n a. b! c?", 1, "a.");
+ run_test (gtk_source_vim_text_object_new_inner_sentence (), "\n a. b! c?", 2, "a.");
+
+ run_test (gtk_source_vim_text_object_new_a_sentence (), "a. b! c?", 0, "a. ");
+ run_test (gtk_source_vim_text_object_new_a_sentence (), " a. b! c?", 0, " a. ");
+ run_test (gtk_source_vim_text_object_new_a_sentence (), "\n a. b! c?", 1, "a. ");
+ run_test (gtk_source_vim_text_object_new_a_sentence (), "\n a. b! c?", 2, "a. ");
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]