-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-str.c
More file actions
41 lines (32 loc) · 726 Bytes
/
test-str.c
File metadata and controls
41 lines (32 loc) · 726 Bytes
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
#include <unit.h>
#include <str.c>
static void test_space(void);
static void test_ident(void);
static void test_ident_empty(void);
struct unit_test tests[] = {
{.msg="getting the length of non-space characters in a buffer",
.fun=unit_list(test_ident),},
{.msg="getting the length of an empty identifier",
.fun=unit_list(test_ident_empty),},
{.msg="getting the length of a sequence of spaces",
.fun=unit_list(test_space),},
};
#include <unit.t>
void
test_ident(void)
{
char *hii="hii";
expect(3, eat_ident(hii, strlen(hii)));
}
void
test_ident_empty(void)
{
char *ws=" \n\t";
expect(0, eat_ident(ws, strlen(ws)));
}
void
test_space(void)
{
char *ws=" \nstop";
expect(3, eat_spaces(ws, strlen(ws)));
}