File: test_usermanager.tcc

package info (click to toggle)
uhub 0.4.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid, stretch
  • size: 1,436 kB
  • ctags: 2,270
  • sloc: ansic: 18,123; xml: 575; perl: 568; sh: 368; makefile: 24
file content (89 lines) | stat: -rw-r--r-- 1,192 bytes parent folder | download | duplicates (3)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <uhub.h>

#define MAX_USERS 64

static struct hub_user_manager* uman = 0;
static struct hub_user um_user[MAX_USERS];

EXO_TEST(um_init_1, {
	sid_t s;
	uman = uman_init();
	
	for (s = 0; s < MAX_USERS; s++)
	{
		memset(&um_user[s], 0, sizeof(struct hub_user));
		um_user[s].id.sid = s;
	}
	return !!uman;
});

EXO_TEST(um_shutdown_1, {
	return uman_shutdown(0) == -1;
});

EXO_TEST(um_shutdown_2, {
	return uman_shutdown(uman) == 0;
});

EXO_TEST(um_init_2, {
	uman = uman_init();
	return !!uman;
});

EXO_TEST(um_add_1, {
	return uman_add(uman, &um_user[0]) == 0;
});

EXO_TEST(um_size_1, {
	return uman->count == 1;
});


EXO_TEST(um_remove_1, {
	return uman_remove(uman, &um_user[0]) == 0;
});

EXO_TEST(um_size_2, {
	return uman->count == 0;
});


EXO_TEST(um_add_2, {
	int i;
	for (i = 0; i < MAX_USERS; i++)
	{
		if (uman_add(uman, &um_user[i]) != 0)
			return 0;
	}
	return 1;
});

EXO_TEST(um_size_3, {
	return uman->count == MAX_USERS;
});

EXO_TEST(um_remove_2, {
	int i;
	for (i = 0; i < MAX_USERS; i++)
	{
		if (uman_remove(uman, &um_user[i]) != 0)
			return 0;
	}
	return 1;
});












/* Last test */
EXO_TEST(um_shutdown_4, {
	return uman_shutdown(uman) == 0;
});