-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
69 lines (55 loc) · 1.07 KB
/
test.c
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
#include <stdio.h>
#include <assert.h>
#include "fifo.h"
int main(void)
{
MAKE_FIFO(tf, 4);
int i;
assert(DEPTH(tf)==0);
assert(FREE(tf)==4);
for (i=0; i<3; i++)
{
PUT(tf, i);
assert(DEPTH(tf)==i+1);
assert(FREE(tf)==4-i-1);
}
assert(!IS_FULL(tf));
assert(IS_NOT_FULL(tf));
assert(!OVFL(tf));
PUT(tf, 5);
assert(DEPTH(tf)==4);
assert(FREE(tf)==0);
assert(IS_FULL(tf));
assert(!IS_NOT_FULL(tf));
assert(!OVFL(tf));
REMOVE(tf);
REMOVE(tf);
assert(DEPTH(tf)==2);
for (i=0; i<2; i++)
{
PUT(tf, i);
assert(DEPTH(tf)==3+i);
}
REMOVE(tf);
REMOVE(tf);
REMOVE(tf);
REMOVE(tf);
assert(DEPTH(tf)==0);
assert(FREE(tf)==4);
for (i=0; i<4; i++)
{
PUT(tf, i);
assert(DEPTH(tf)==i+1);
assert(FREE(tf)==4-i-1);
}
assert(!OVFL(tf));
PUT(tf, 5);
assert(OVFL(tf));
/* SVP 21JAN2023 */
puts("Calling FLUSH(), then testing with DEPTH() and FREE()");
FLUSH(tf);
assert(IS_EMPTY(tf));
assert(DEPTH(tf) == 0); /* Both of these fail */
assert(FREE(tf) == 4);
return 0;
}