xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit d24929dbef210309d1d073dc6dae2fe2b29f1252

Test parameters for :yank and :delete better
Cover cases of invalid input.
Author: xaizek
Author date (UTC): 2026-03-21 13:11
Committer name: xaizek
Committer date (UTC): 2026-03-21 13:54
Parent(s): 2b226c3e1142001f5f61ce10e97fc97ea26914f8
Signing key: 99DC5E4DB05F6BE2
Tree: ef1f41c8b26bcca11981c8a1beada1cbb0409c47
File Lines added Lines deleted
tests/commands/misc_fops.c 31 0
File tests/commands/misc_fops.c changed (mode: 100644) (index 0dc15e04c..b414e5b82)
... ... TEST(zero_count_is_rejected)
284 284 { {
285 285 const char *expected = "Count argument can't be zero"; const char *expected = "Count argument can't be zero";
286 286
287 ui_sb_msg("");
288 assert_failure(cmds_dispatch("delete 0", &lwin, CIT_COMMAND));
289 assert_string_equal(expected, ui_sb_last());
290
287 291 ui_sb_msg(""); ui_sb_msg("");
288 292 assert_failure(cmds_dispatch("delete a 0", &lwin, CIT_COMMAND)); assert_failure(cmds_dispatch("delete a 0", &lwin, CIT_COMMAND));
289 293 assert_string_equal(expected, ui_sb_last()); assert_string_equal(expected, ui_sb_last());
290 294
295 ui_sb_msg("");
296 assert_failure(cmds_dispatch("yank 0", &lwin, CIT_COMMAND));
297 assert_string_equal(expected, ui_sb_last());
298
291 299 ui_sb_msg(""); ui_sb_msg("");
292 300 assert_failure(cmds_dispatch("yank a 0", &lwin, CIT_COMMAND)); assert_failure(cmds_dispatch("yank a 0", &lwin, CIT_COMMAND));
293 301 assert_string_equal(expected, ui_sb_last()); assert_string_equal(expected, ui_sb_last());
294 302 } }
295 303
304 TEST(range_and_count_fails)
305 {
306 /* The first parameter (register) is not a register. */
307 ui_sb_msg("");
308 assert_failure(cmds_dispatch("delete ( 0", &lwin, CIT_COMMAND));
309 assert_string_equal("Trailing characters", ui_sb_last());
310
311 /* The only parameter (register) is not a register. */
312 ui_sb_msg("");
313 assert_failure(cmds_dispatch("delete #", &lwin, CIT_COMMAND));
314 assert_string_equal("Trailing characters", ui_sb_last());
315
316 /* The second parameter (count) is not a number. */
317 ui_sb_msg("");
318 assert_failure(cmds_dispatch("delete a e", &lwin, CIT_COMMAND));
319 assert_string_equal("Trailing characters", ui_sb_last());
320
321 /* The only parameter (count) is not a number. */
322 ui_sb_msg("");
323 assert_failure(cmds_dispatch("delete a e", &lwin, CIT_COMMAND));
324 assert_string_equal("Trailing characters", ui_sb_last());
325 }
326
296 327 TEST(non_zero_count_is_handled) TEST(non_zero_count_is_handled)
297 328 { {
298 329 regs_init(); regs_init();
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master