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.
<root> / tests / menus / undolist.c (a94f54a56c220a6b90fc21cc758f1ff5233af0bd) (1,876B) (mode 100644) [raw]
#include <stic.h>

#include "../../src/engine/keys.h"
#include "../../src/menus/undolist_menu.h"
#include "../../src/modes/modes.h"
#include "../../src/modes/wk.h"
#include "../../src/ui/statusbar.h"
#include "../../src/ui/ui.h"
#include "../../src/status.h"
#include "../../src/undo.h"

static OpsResult exec_func(OPS op, void *data, const char src[],
		const char dst[]);
static int op_avail(OPS op);

SETUP()
{
	static int undo_levels = 10;
	un_init(&exec_func, &op_avail, NULL, &undo_levels);

	modes_init();

	curr_stats.load_stage = -1;
}

TEARDOWN()
{
	un_reset();

	vle_keys_reset();

	curr_stats.load_stage = 0;
}

TEST(empty_undolist_menu_is_not_displayed)
{
	ui_sb_msg("");
	assert_failure(show_undolist_menu(&lwin, 0));
	assert_string_equal("Undolist is empty", ui_sb_last());

	ui_sb_msg("");
	assert_failure(show_undolist_menu(&lwin, 1));
	assert_string_equal("Undolist is empty", ui_sb_last());
}

TEST(undolist_allows_resetting_current_position)
{
	un_group_open("msg1");
	assert_success(un_group_add_op(OP_MOVE, NULL, NULL, "do_msg1", "undo_msg1"));
	un_group_close();

	ui_sb_msg("");
	assert_success(show_undolist_menu(&lwin, 0));
	assert_string_equal("", ui_sb_last());

	/* Pass key that's unhandled by both undolist menu and menu mode. */
	(void)vle_keys_exec_timed_out(WK_R);

	(void)vle_keys_exec_timed_out(WK_j);
	(void)vle_keys_exec_timed_out(WK_r);
	assert_int_equal(UN_ERR_NONE, un_group_undo());
	(void)vle_keys_exec_timed_out(WK_k);
	(void)vle_keys_exec_timed_out(WK_r);
	assert_int_equal(UN_ERR_SUCCESS, un_group_undo());
	(void)vle_keys_exec_timed_out(WK_q);
}

static OpsResult
exec_func(OPS op, void *data, const char src[], const char dst[])
{
	return OPS_SUCCEEDED;
}

static int
op_avail(OPS op)
{
	return (op == OP_MOVE);
}

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 : */
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