Esempio n. 1
0
static void
test_two_matches(void)
{
    char *buf;

    assert_int_equal(0, add_completion("mountpoint"));
    completion_group_end();
    assert_int_equal(0, add_completion("mount"));
    completion_group_end();

    assert_int_equal(0, add_completion("mount"));

    buf = next_completion();
    assert_string_equal("mountpoint", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mountpoint", buf);
    free(buf);
}
Esempio n. 2
0
static void
test_umbiguous_begin(void)
{
    char *buf;

    assert_int_equal(0, add_completion("sort"));
    assert_int_equal(0, add_completion("sortorder"));
    assert_int_equal(0, add_completion("sortnumbers"));
    completion_group_end();

    assert_int_equal(0, add_completion("sort"));

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sortnumbers", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sortorder", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("sort", buf);
    free(buf);
}
Esempio n. 3
0
static void
test_removes_duplicates(void)
{
    char *buf;

    assert_int_equal(0, add_completion("mou"));
    assert_int_equal(0, add_completion("mount"));
    assert_int_equal(0, add_completion("mount"));
    completion_group_end();

    assert_int_equal(0, add_completion("m"));

    buf = next_completion();
    assert_string_equal("mou", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mount", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("m", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("mou", buf);
    free(buf);
}
Esempio n. 4
0
static void
test_general(void)
{
    char *buf;

    assert_int_equal(0, add_completion("abc"));
    assert_int_equal(0, add_completion("acd"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("abc", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("acd", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abc", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("acd", buf);
    free(buf);
}
Esempio n. 5
0
static void
test_envvars_completion(void)
{
	char buf[] = "$VAR_";
	const char *start;
	char *completed;

	complete_variables(buf, &start);
	assert_true(&buf[1] == start);

	completed = next_completion();
	assert_string_equal("VAR_A", completed);
	free(completed);

	completed = next_completion();
	assert_string_equal("VAR_B", completed);
	free(completed);

	completed = next_completion();
	assert_string_equal("VAR_C", completed);
	free(completed);

	completed = next_completion();
	assert_string_equal("VAR_", completed);
	free(completed);
}
Esempio n. 6
0
static void
test_rewind_one_unambiguous_completion(void)
{
    char *buf;

    assert_int_equal(0, add_completion("abcd"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);

    rewind_completion();

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("abcd", buf);
    free(buf);
}
Esempio n. 7
0
static void
test_order(void)
{
    char *buf;

    assert_int_equal(0, add_completion("aa"));
    assert_int_equal(0, add_completion("az"));
    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    set_completion_order(1);

    buf = next_completion();
    assert_string_equal("az", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("aa", buf);
    free(buf);

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
}
Esempio n. 8
0
File: builtin.c Progetto: sklnd/vifm
static void
test_empty_line_completion(void)
{
	char *buf;

	reset_completion();
	assert_int_equal(0, complete_cmd(""));

	buf = next_completion();
	assert_string_equal("!", buf);
	free(buf);

	buf = next_completion();
	assert_string_equal("alink", buf);
	free(buf);
}
Esempio n. 9
0
static void
test_skip_abbreviations(void)
{
	char *completion;

	reset_completion();
	assert_int_equal(0, complete_cmd("d"));
	assert_int_equal(3, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("delcommand", completion);
	free(completion);
	completion = next_completion();
	assert_string_equal("delete", completion);
	free(completion);
}
Esempio n. 10
0
static void
test_skip_complete_args(void)
{
	char *completion;

	reset_completion();
	assert_int_equal(17, complete_cmd("% dele fast slow "));
	assert_int_equal(3, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("fastrun", completion);
	free(completion);
	completion = next_completion();
	assert_string_equal("followlinks", completion);
	free(completion);
}
Esempio n. 11
0
static void
test_skip_goto(void)
{
	char *completion;

	reset_completion();
	assert_int_equal(0, complete_cmd(""));
	assert_int_equal(5, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("comclear", completion);
	free(completion);
	completion = next_completion();
	assert_string_equal("command", completion);
	free(completion);
	completion = next_completion();
	assert_string_equal("delcommand", completion);
	free(completion);
}
Esempio n. 12
0
File: builtin.c Progetto: sklnd/vifm
static void
test_set(void)
{
	char *buf;

	reset_completion();
	assert_int_equal(0, complete_cmd("se"));

	buf = next_completion();
	assert_string_equal("set", buf);
	free(buf);
}
Esempio n. 13
0
static void
test_vars_empty_completion(void)
{
	char buf[] = "";
	const char *start;
	char *completed;

	complete_variables(buf, &start);
	assert_true(&buf[0] == start);
	completed = next_completion();
	assert_string_equal("", completed);
	free(completed);
}
Esempio n. 14
0
static void
test_one_element_completion(void)
{
    char *buf;

    completion_group_end();

    assert_int_equal(0, add_completion("a"));

    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
    buf = next_completion();
    assert_string_equal("a", buf);
    free(buf);
}
Esempio n. 15
0
static void
test_dont_remove_range(void)
{
	char *completion;

	reset_completion();
	assert_int_equal(2, complete_cmd("% del"));
	assert_int_equal(3, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("delcommand", completion);
	free(completion);

	reset_completion();
	assert_int_equal(1, complete_cmd("3del"));
	assert_int_equal(3, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("delcommand", completion);
	free(completion);
}
Esempio n. 16
0
static void
test_do_not_complete_removed_variables(void)
{
	char buf[] = "$VAR_";
	const char *start;
	char *completed;

	assert_int_equal(0, unlet_variables("$VAR_B"));

	complete_variables(buf, &start);
	assert_true(&buf[1] == start);

	completed = next_completion();
	assert_string_equal("VAR_A", completed);
	free(completed);

	completed = next_completion();
	assert_string_equal("VAR_C", completed);
	free(completed);

	completed = next_completion();
	assert_string_equal("VAR_", completed);
	free(completed);
}
Esempio n. 17
0
static void
test_delc_completion(void)
{
	char *completion;

	assert_int_equal(0, execute_cmd("command udf a"));

	reset_completion();
	assert_int_equal(5, complete_cmd("delc u"));
	assert_int_equal(2, get_completion_count());
	if(get_completion_count() == 0)
		return;
	completion = next_completion();
	assert_string_equal("udf", completion);
	free(completion);
}