summaryrefslogtreecommitdiff
path: root/tests/unit/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-05 20:28:11 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-05 20:28:11 +0200
commit6d7f10ef2010a7b0c31712e06d7db66c3ab6a2ff (patch)
treee13463a6a6ea846bce3c804f5720ea83af049767 /tests/unit/core
parent25d7192677f8a415cd9ba94229d86aecb9ca5797 (diff)
downloadweechat-6d7f10ef2010a7b0c31712e06d7db66c3ab6a2ff.zip
core: fix execution of multiple commands separated by newline when there are no spaces
For example typing this on core buffer: /t1 /t2 was not executing the two commands but sent the text to the buffer instead. This is because WeeChat thinks it's a path, and the newline should indicate it's not (like a space before the next slash: "/t1 /t2" is a command, not a path, but "/t1/t2" is considered a path).
Diffstat (limited to 'tests/unit/core')
-rw-r--r--tests/unit/core/test-core-string.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/core/test-core-string.cpp b/tests/unit/core/test-core-string.cpp
index 87ab40dd2..a74e0cca3 100644
--- a/tests/unit/core/test-core-string.cpp
+++ b/tests/unit/core/test-core-string.cpp
@@ -2490,6 +2490,7 @@ TEST(CoreString, InputForBuffer)
POINTERS_EQUAL(NULL, string_input_for_buffer ("/"));
POINTERS_EQUAL(NULL, string_input_for_buffer ("/abc"));
+ /* not commands */
str = strdup ("");
STRCMP_EQUAL(str, string_input_for_buffer (str));
free (str);
@@ -2511,6 +2512,27 @@ TEST(CoreString, InputForBuffer)
str = strdup ("//abc");
STRCMP_EQUAL(str + 1, string_input_for_buffer (str));
free (str);
+ str = strdup ("/abc/def /ghi");
+ STRCMP_EQUAL(str, string_input_for_buffer (str));
+ free (str);
+ str = strdup ("/abc/def /ghi");
+ STRCMP_EQUAL(str, string_input_for_buffer (str));
+ free (str);
+
+ /* commands */
+ POINTERS_EQUAL(NULL, string_input_for_buffer (NULL));
+ str = strdup ("/");
+ POINTERS_EQUAL(NULL, string_input_for_buffer (str));
+ free (str);
+ str = strdup ("/abc");
+ POINTERS_EQUAL(NULL, string_input_for_buffer (str));
+ free (str);
+ str = strdup ("/abc /def");
+ POINTERS_EQUAL(NULL, string_input_for_buffer (str));
+ free (str);
+ str = strdup ("/abc\n/def");
+ POINTERS_EQUAL(NULL, string_input_for_buffer (str));
+ free (str);
/* test with custom command chars */
config_file_option_set (config_look_command_chars, "öï", 1);