File: classes.c

package info (click to toggle)
vifm 0.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,252 kB
  • sloc: ansic: 179,567; sh: 5,445; makefile: 723; perl: 347; python: 76; xml: 26
file content (67 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stic.h>

#include <stdlib.h>

#include "../../src/filetype.h"
#include "../../src/status.h"
#include "test.h"

TEST(enumeration)
{
	const char *prog_cmd;

	set_programs("*.[ch]", "c file", 0, 0);

	assert_true((prog_cmd = ft_get_program("main.cpp")) == NULL);
	assert_true((prog_cmd = ft_get_program("main.hpp")) == NULL);

	assert_true((prog_cmd = ft_get_program("main.c")) != NULL);
	assert_string_equal("c file", prog_cmd);

	assert_true((prog_cmd = ft_get_program("main.h")) != NULL);
	assert_string_equal("c file", prog_cmd);
}

TEST(negation_with_emark)
{
	const char *prog_cmd;

	set_programs("*.[!ch]", "not c file", 0, 0);

	assert_false((prog_cmd = ft_get_program("main.c")) != NULL);
	assert_false((prog_cmd = ft_get_program("main.h")) != NULL);

	assert_true((prog_cmd = ft_get_program("main.o")) != NULL);
	assert_string_equal("not c file", prog_cmd);
}

TEST(negation_with_hat)
{
	const char *prog_cmd;

	set_programs("*.[^ch]", "not c file", 0, 0);

	assert_false((prog_cmd = ft_get_program("main.c")) != NULL);
	assert_false((prog_cmd = ft_get_program("main.h")) != NULL);

	assert_true((prog_cmd = ft_get_program("main.o")) != NULL);
	assert_string_equal("not c file", prog_cmd);
}

TEST(ranges)
{
	const char *prog_cmd;

	set_programs("*.[0-9]", "part file", 0, 0);

	assert_false((prog_cmd = ft_get_program("main.A")) != NULL);

	assert_true((prog_cmd = ft_get_program("main.0")) != NULL);
	assert_string_equal("part file", prog_cmd);

	assert_true((prog_cmd = ft_get_program("main.8")) != NULL);
	assert_string_equal("part file", prog_cmd);
}

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
/* vim: set cinoptions+=t0 filetype=c : */