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 / commands / autocd.c (555ad0b7a2ad5a7ec8d18488f19fa3743d98c522) (1,620B) (mode 100644) [raw]
#include <stic.h>

#include <test-utils.h>

#include "../../src/cfg/config.h"
#include "../../src/compat/os.h"
#include "../../src/engine/cmds.h"
#include "../../src/ui/ui.h"
#include "../../src/utils/path.h"
#include "../../src/cmd_core.h"

static char test_data[PATH_MAX + 1];
static char read_path[PATH_MAX + 1];

SETUP_ONCE()
{
	make_abs_path(test_data, sizeof(test_data), TEST_DATA_PATH, "", NULL);
	make_abs_path(read_path, sizeof(read_path), TEST_DATA_PATH, "read", NULL);
}

SETUP()
{
	curr_view = &lwin;
	other_view = &rwin;

	conf_setup();
	view_setup(&lwin);

	make_abs_path(lwin.curr_dir, sizeof(lwin.curr_dir), TEST_DATA_PATH, "", NULL);

	cmds_init();

	cfg.auto_cd = 1;
}

TEARDOWN()
{
	curr_view = NULL;
	other_view = NULL;

	conf_teardown();
	view_teardown(&lwin);

	vle_cmds_reset();

	cfg.auto_cd = 0;
}

TEST(existing_dir)
{
	assert_success(cmds_dispatch1("read", &lwin, CIT_COMMAND));
	assert_true(paths_are_equal(lwin.curr_dir, read_path));
}

TEST(parent_dir)
{
	assert_success(cmds_dispatch1("read", &lwin, CIT_COMMAND));
	assert_true(paths_are_equal(lwin.curr_dir, read_path));

	assert_success(cmds_dispatch1("..", &lwin, CIT_COMMAND));
	assert_true(paths_are_equal(lwin.curr_dir, test_data));

	assert_success(cmds_dispatch1("read", &lwin, CIT_COMMAND));
	assert_true(paths_are_equal(lwin.curr_dir, read_path));
}

TEST(ambiguity_and_error)
{
	assert_failure(cmds_dispatch1("compare/a", &lwin, CIT_COMMAND));
	assert_true(paths_are_equal(lwin.curr_dir, test_data));
}

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