-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.commands
More file actions
143 lines (125 loc) · 2.54 KB
/
test.commands
File metadata and controls
143 lines (125 loc) · 2.54 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
source queue.py
define print_status
printf "%-40s %s\n", $arg0 ":", "$arg1"
end
define test_outer
queue-size $arg0_head link
if $ != MAX_ITEMS
print_status "$arg0_head size" FAIL
set $rc = -1
end
queue-size $arg0_single_head link
if $ != 1
print_status "$arg0_single_head size" FAIL
set $rc = -1
end
queue-size $arg0_empty_head link
if $ != 0
print_status "$arg0_empty_head size" FAIL
set $rc = -1
end
set $idx = 0
while $idx < MAX_ITEMS
queue-at $arg0_head link $idx
if $.id != $idx + 1
print_status "$arg0_head at" FAIL
set $idx = MAX_ITEMS
set $rc = -1
end
set $idx = $idx + 1
end
# These foreach tests assume MAX_ITEMS == 128
set $idx = 0
queue-foreach $arg0_head link
while $idx < MAX_ITEMS
set $val = $$127.id
if $val != $idx + 1
print_status "$arg0_head foreach" FAIL
set $idx = MAX_ITEMS
set $rc = -1
end
set $idx = $idx + 1
# Print the value to advance $$, so that a constant 127 can be used
print $val
end
set $idx = 0
queue-foreach $arg0_head link id
while $idx < MAX_ITEMS
set $val = $$127
if $val != $idx + 1
print_status "$arg0_head foreach id" FAIL
set $idx = MAX_ITEMS
set $rc = -1
end
set $idx = $idx + 1
print $val
end
end
define test_inner
queue-size $arg0_inner_head inner.link
if $ != MAX_ITEMS
print_status "$arg0_inner_head size" FAIL
set $rc = -1
end
queue-size $arg0_inner_single_head inner.link
if $ != 1
print_status "$arg0_inner_single_head size" FAIL
set $rc = -1
end
queue-size $arg0_inner_empty_head inner.link
if $ != 0
print_status "$arg0_inner_empty_head size" FAIL
set $rc = -1
end
set $idx = 0
while $idx < MAX_ITEMS
queue-at $arg0_inner_head inner.link $idx
if $.id != $idx + 1
print_status "$arg0_inner_head at" FAIL
set $idx = MAX_ITEMS
set $rc = -1
end
set $idx = $idx + 1
end
set $idx = 0
queue-foreach $arg0_inner_head inner.link id
while $idx < MAX_ITEMS
set $val = $$127
if $val != $idx + 1
print_status "$arg0_inner_head foreach id" FAIL
set $idx = MAX_ITEMS
set $rc = -1
end
set $idx = $idx + 1
# Print the value to advance $$, so that a constant 127 can be used
print $val
end
end
define test_queue
set $rc = 0
test_outer $arg0
test_inner $arg0
if $rc == 0
print_status "$arg0" OK
end
end
define test_tree
set $rc = 0
test_outer $arg0
if $rc == 0
print_status "$arg0" OK
end
end
set pagination off
b main
commands 1
test_queue LIST
test_queue SLIST
test_queue SIMPLEQ
test_queue TAILQ
test_queue STAILQ
test_queue CIRCLEQ
test_tree SPLAY
test_tree RB
end
run