From 224f81e2502bb4b8e96517a516d4bee32f52648c Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 17 Dec 2022 17:05:22 +0100 Subject: [PATCH] fish_tests: use default argument for abbreviation tests Some tests place the cursor at the end of the command line. This is the obvious default, so let's make it a default argument. --- src/fish_tests.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 2e854832e..ed6c4fde7 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -2505,9 +2505,9 @@ static void test_abbreviations() { maybe_t result; auto expand_abbreviation_in_command = [](const wcstring &cmdline, - size_t cursor_pos) -> maybe_t { - if (auto replacement = reader_expand_abbreviation_at_cursor(cmdline, cursor_pos, - parser_t::principal_parser())) { + maybe_t cursor_pos = {}) -> maybe_t { + if (auto replacement = reader_expand_abbreviation_at_cursor( + cmdline, cursor_pos.value_or(cmdline.size()), parser_t::principal_parser())) { wcstring cmdline_expanded = cmdline; std::vector colors{cmdline_expanded.size()}; apply_edit(&cmdline_expanded, &colors, edit_t{replacement->range, replacement->text}); @@ -2544,21 +2544,21 @@ static void test_abbreviations() { err(L"gc incorrectly expanded on line %ld to '%ls'", (long)__LINE__, result->c_str()); // If commands should be expanded. - result = expand_abbreviation_in_command(L"if gc", const_strlen(L"if gc")); + result = expand_abbreviation_in_command(L"if gc"); if (!result) err(L"gc not expanded on line %ld", (long)__LINE__); if (result != L"if git checkout") err(L"gc incorrectly expanded on line %ld to '%ls'", (long)__LINE__, result->c_str()); // Others should not be. - result = expand_abbreviation_in_command(L"of gc", const_strlen(L"of gc")); + result = expand_abbreviation_in_command(L"of gc"); if (result) err(L"gc incorrectly expanded on line %ld", (long)__LINE__); // Others should not be. - result = expand_abbreviation_in_command(L"command gc", const_strlen(L"command gc")); + result = expand_abbreviation_in_command(L"command gc"); if (result) err(L"gc incorrectly expanded on line %ld", (long)__LINE__); // yin/yang expands everywhere. - result = expand_abbreviation_in_command(L"command yin", const_strlen(L"command yin")); + result = expand_abbreviation_in_command(L"command yin"); if (!result) err(L"gc not expanded on line %ld", (long)__LINE__); if (result != L"command yang") { err(L"command yin incorrectly expanded on line %ld to '%ls'", (long)__LINE__,