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 / cmds / parsing.c (4d6cbb932f0967f6dc6ef0bfdfc102b7b0ef7ba8) (1,708B) (mode 100644) [raw]
#include <stic.h>

#include "../../src/engine/cmds.h"

static int dummy_cmd(const cmd_info_t *cmd_info);

TEST(post_name_no_emark)
{
	cmd_add_t command = {
	  .name = "test",        .abbr = NULL,  .id = -1,      .descr = "descr",
	  .flags = 0,
	  .handler = &dummy_cmd, .min_args = 0, .max_args = 1,
	};

	assert_success(add_builtin_cmd(command.name, BUILTIN_CMD, &command));

	cmd_info_t info;

	assert_non_null(vle_cmds_parse("test a", &info));
	assert_string_equal(" a", info.post_name);
	assert_string_equal("a", info.raw_args);

	assert_non_null(vle_cmds_parse("test !", &info));
	assert_string_equal(" !", info.post_name);
	assert_string_equal("!", info.raw_args);

	assert_non_null(vle_cmds_parse("test!", &info));
	assert_string_equal("!", info.post_name);
	assert_string_equal("!", info.raw_args);
}

TEST(post_name_emark)
{
	cmd_add_t command = {
	  .name = "test",        .abbr = NULL,  .id = -1,      .descr = "descr",
	  .flags = HAS_EMARK,
	  .handler = &dummy_cmd, .min_args = 0, .max_args = 1,
	};

	assert_success(add_builtin_cmd(command.name, BUILTIN_CMD, &command));

	cmd_info_t info;

	assert_non_null(vle_cmds_parse("test a", &info));
	assert_string_equal(" a", info.post_name);
	assert_string_equal("a", info.raw_args);

	assert_non_null(vle_cmds_parse("test !", &info));
	assert_string_equal(" !", info.post_name);
	assert_string_equal("!", info.raw_args);

	assert_non_null(vle_cmds_parse("test!", &info));
	assert_string_equal("", info.post_name);
	assert_string_equal("", info.raw_args);
}

static int
dummy_cmd(const cmd_info_t *cmd_info)
{
	return 0;
}

/* 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