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 / last_argument.c (3bb564dd33b7e127a09e7f20727166528ac6a63d) (1,551B) (mode 100644) [raw]
#include <stic.h>

#include <string.h>

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

extern cmds_conf_t cmds_conf;

cmd_info_t user_cmd_info;

TEST(empty_ok)
{
	const char cmd[] = "";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd);
	assert_int_equal(0, len);
}

TEST(one_word_ok)
{
	const char cmd[] = "a";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd);
	assert_int_equal(1, len);
}

TEST(two_words_ok)
{
	const char cmd[] = "b a";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd + 2);
	assert_int_equal(1, len);
}

TEST(trailing_spaces_ok)
{
	const char cmd[] = "a    ";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd);
	assert_int_equal(1, len);
}

TEST(single_quotes_ok)
{
	const char cmd[] = "b  'hello'";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd + 3);
	assert_int_equal(7, len);
}

TEST(double_quotes_ok)
{
	const char cmd[] = "b \"hi\"";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd + 2);
	assert_int_equal(4, len);
}

TEST(ending_space_ok)
{
	const char cmd[] = "b a\\ ";
	size_t len;
	const char *last;
	last = vle_cmds_last_arg(cmd, 0, &len);

	assert_true(last == cmd + 2);
	assert_int_equal(3, len);
}

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