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 / options / suite.c (722e14b6bdb1966c85d39adb4edb3c3735c88a20) (3,362B) (mode 100644) [raw]
#include <stic.h>

#include <string.h>

#include "../../src/engine/options.h"
#include "../../src/utils/macros.h"

static void cpoptions_handler(OPT_OP op, optval_t val);
static void cdpath_handler(OPT_OP op, optval_t val);
static void fastrun_handler(OPT_OP op, optval_t val);
static void fusehome_handler(OPT_OP op, optval_t val);
static void tabstop_handler(OPT_OP op, optval_t val);
static void vifminfo_handler(OPT_OP op, optval_t val);
static void dummy_handler(OPT_OP op, optval_t val);

char cpoptions[10];
int cpoptions_handler_calls;
int fastrun;
int fusehome_handler_calls;
int tabstop;
const char *value;
int vifminfo;
int vifminfo_handler_calls;

static const char *cpoptions_vals[][2] = {
	{ "abc", "descr" },
	{ "a", "descr" },
	{ "b", "descr" },
	{ "c", "descr" },
};

static const char *sort_enum[][2] = {
	{ "ext",   "descr" },
	{ "name",  "descr" },
	{ "gid",   "descr" },
	{ "gname", "descr" },
	{ "mode",  "descr" },
	{ "uid",   "descr" },
	{ "uname", "descr" },
	{ "size",  "descr" },
	{ "atime", "descr" },
	{ "ctime", "descr" },
	{ "mtime", "descr" },
};

static const char *vifminfo_set[][2] = {
	{ "options",   "descr" },
	{ "filetypes", "descr" },
	{ "commands",  "descr" },
	{ "bookmarks", "descr" },
	{ "tui",       "descr" },
	{ "dhistory",  "descr" },
	{ "state",     "descr" },
	{ "cs",        "descr" },
};

DEFINE_SUITE();

SETUP()
{
	static int option_changed;
	optval_t val;

	vle_opts_init(&option_changed, NULL);

	val.str_val = "";
	cpoptions[0] = '\0';
	vle_opts_add("cpoptions", "cpo", "descr", OPT_CHARSET, OPT_GLOBAL,
			ARRAY_LEN(cpoptions_vals), cpoptions_vals, cpoptions_handler, val);

	val.str_val = "";
	vle_opts_add("cdpath", "cd", "descr", OPT_STRLIST, OPT_GLOBAL, 0, NULL,
			cdpath_handler, val);

	val.bool_val = fastrun = 0;
	vle_opts_add("fastrun", "fr", "descr", OPT_BOOL, OPT_GLOBAL, 0, NULL,
			fastrun_handler, val);

	value = val.str_val = "fusehome-default";
	vle_opts_add("fusehome", "fh", "descr", OPT_STR, OPT_GLOBAL, 0, NULL,
			fusehome_handler, val);

	val.enum_item = 1;
	vle_opts_add("sort", "so", "descr", OPT_ENUM, OPT_GLOBAL,
			ARRAY_LEN(sort_enum), sort_enum, &dummy_handler, val);

	val.bool_val = 1;
	vle_opts_add("sortorder", "", "descr", OPT_BOOL, OPT_GLOBAL, 0, NULL,
			&dummy_handler, val);

	val.int_val = tabstop = 8;
	vle_opts_add("tabstop", "ts", "descr", OPT_INT, OPT_GLOBAL, 0, NULL,
			&tabstop_handler, val);

	val.set_items = vifminfo = 0;
	vle_opts_add("vifminfo", "", "descr", OPT_SET, OPT_GLOBAL,
			ARRAY_LEN(vifminfo_set), vifminfo_set, &vifminfo_handler, val);
}

TEARDOWN()
{
	vle_opts_reset();
}

static void
cpoptions_handler(OPT_OP op, optval_t val)
{
	strcpy(cpoptions, val.str_val);
	cpoptions_handler_calls++;
}

static void
cdpath_handler(OPT_OP op, optval_t val)
{
	value = val.str_val;
}

static void
fastrun_handler(OPT_OP op, optval_t val)
{
	fastrun = val.bool_val;
}

static void
fusehome_handler(OPT_OP op, optval_t val)
{
	value = val.str_val;
	fusehome_handler_calls++;
}

static void
tabstop_handler(OPT_OP op, optval_t val)
{
	tabstop = val.int_val;
}

static void
vifminfo_handler(OPT_OP op, optval_t val)
{
	vifminfo = val.set_items;
	vifminfo_handler_calls++;
}

static void
dummy_handler(OPT_OP op, optval_t val)
{
}

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