File: functional.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 (65 lines) | stat: -rw-r--r-- 1,264 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
#include <stic.h>

#include <ctype.h> /* isdigit() */

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

static int
less_than_5(int x)
{
    return x < 5;
}

TEST(all_all_are_true)
{
	assert_int_equal(1, ALL(less_than_5, 1, -2, 3));
	assert_int_equal(1, ALL(isdigit, '1', '9'));
}

TEST(all_all_are_false)
{
	assert_int_equal(0, ALL(less_than_5, 10, 20, 30));
}

TEST(all_one_is_true)
{
	assert_int_equal(0, ALL(less_than_5, 10, 0, 30));
	assert_int_equal(0, ALL(isdigit, 'z', '9'));
}

TEST(none_all_are_true)
{
	assert_int_equal(0, NONE(less_than_5, 1, -2, 3));
	assert_int_equal(0, NONE(isdigit, '1', '9'));
}

TEST(none_all_are_false)
{
	assert_int_equal(1, NONE(less_than_5, 10, 20, 30));
	assert_int_equal(1, NONE(isdigit, 'z', 'a'));
}

TEST(none_one_is_true)
{
	assert_int_equal(0, NONE(less_than_5, 10, 0, 30));
}

TEST(any_all_are_true)
{
	assert_int_equal(1, ANY(less_than_5, 1, -2, 3));
}

TEST(any_all_are_false)
{
	assert_int_equal(0, ANY(less_than_5, 10, 20, 30));
	assert_int_equal(0, ANY(isdigit, 'z', 'a'));
}

TEST(any_one_is_true)
{
	assert_int_equal(1, ANY(less_than_5, 10, 0, 30));
	assert_int_equal(1, ANY(isdigit, 'z', '9'));
}

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