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 29deae3da357e7616c6f5716b35400bc4edf414f

Test :messages command
Author: xaizek
Author date (UTC): 2025-05-24 12:40
Committer name: xaizek
Committer date (UTC): 2025-05-24 12:40
Parent(s): a730df16ad722ac9927698f8538aa73016b62b85
Signing key: 99DC5E4DB05F6BE2
Tree: bda92130070cc110f4c7b96ce0297efa08e48b82
File Lines added Lines deleted
tests/commands/misc.c 47 0
File tests/commands/misc.c changed (mode: 100644) (index d70e5e26c..f4941981b)
... ... TEST(mark_command)
664 664 assert_success(cmds_dispatch1("mark? y /tmp", &lwin, CIT_COMMAND)); assert_success(cmds_dispatch1("mark? y /tmp", &lwin, CIT_COMMAND));
665 665 } }
666 666
667 TEST(messages_command)
668 {
669 assert_success(stats_init(&cfg));
670
671 /* Nothing is printed when the history is empty. */
672 ui_sb_msg("");
673 assert_success(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
674 assert_string_equal("", ui_sb_last());
675
676 /* An informational message is stored. */
677 ui_sb_msg("1 info");
678 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
679 assert_string_equal("1 info", ui_sb_last());
680
681 /* An empty message isn't stored. */
682 ui_sb_msg("");
683 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
684 assert_string_equal("1 info", ui_sb_last());
685
686 /* Error messages are stored as well. All messages are appened together. */
687 ui_sb_err("2 error");
688 ui_sb_err("3 error");
689 ui_sb_msg("4 info");
690 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
691 assert_string_equal("1 info\n2 error\n3 error\n4 info", ui_sb_last());
692
693 /* Output of the command is not stored in history. */
694 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
695 assert_string_equal("1 info\n2 error\n3 error\n4 info", ui_sb_last());
696
697 /* History is limited in its size. */
698 unsigned int i;
699 for(i = 0; i < ARRAY_LEN(curr_stats.msgs) - 4; ++i)
700 {
701 ui_sb_msgf("%d info", 4 + i);
702 }
703 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
704 assert_string_starts_with("1 info\n", ui_sb_last());
705 assert_string_ends_with("\n50 info", ui_sb_last());
706
707 /* History only keeps the most recent entries. */
708 ui_sb_msg("51 info");
709 assert_failure(cmds_dispatch1("messages", &lwin, CIT_COMMAND));
710 assert_string_starts_with("2 error\n", ui_sb_last());
711 assert_string_ends_with("\n51 info", ui_sb_last());
712 }
713
667 714 static void static void
668 715 strings_list_is(const strlist_t expected, const strlist_t actual) strings_list_is(const strlist_t expected, const strlist_t actual)
669 716 { {
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