blob: d3225ada681d205f43914a6b59f4bdf4f2263451 (
plain)
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
#!/bin/sh
test_description='check infrastructure for svn importer'
. ./test-lib.sh
uint32_max=4294967295
test_expect_success 'obj pool: store data' '
cat <<-\EOF >expected &&
0
1
EOF
test-obj-pool <<-\EOF >actual &&
alloc one 16
set one 13
test one 13
reset one
EOF
test_cmp expected actual
'
test_expect_success 'obj pool: NULL is offset ~0' '
echo "$uint32_max" >expected &&
echo null one | test-obj-pool >actual &&
test_cmp expected actual
'
test_expect_success 'obj pool: out-of-bounds access' '
cat <<-EOF >expected &&
0
0
$uint32_max
$uint32_max
16
20
$uint32_max
EOF
test-obj-pool <<-\EOF >actual &&
alloc one 16
alloc two 16
offset one 20
offset two 20
alloc one 5
offset one 20
free one 1
offset one 20
reset one
reset two
EOF
test_cmp expected actual
'
test_expect_success 'obj pool: high-water mark' '
cat <<-\EOF >expected &&
0
0
10
20
20
20
EOF
test-obj-pool <<-\EOF >actual &&
alloc one 10
committed one
alloc one 10
commit one
committed one
alloc one 10
free one 20
committed one
reset one
EOF
test_cmp expected actual
'
test_expect_success 'line buffer' '
echo HELLO >expected1 &&
printf "%s\n" "" HELLO >expected2 &&
echo >expected3 &&
printf "%s\n" "" Q | q_to_nul >expected4 &&
printf "%s\n" foo "" >expected5 &&
printf "%s\n" "" foo >expected6 &&
test-line-buffer <<-\EOF >actual1 &&
5
HELLO
EOF
test-line-buffer <<-\EOF >actual2 &&
0
5
HELLO
EOF
q_to_nul <<-\EOF |
1
Q
EOF
test-line-buffer >actual3 &&
q_to_nul <<-\EOF |
0
1
Q
EOF
test-line-buffer >actual4 &&
test-line-buffer <<-\EOF >actual5 &&
5
foo
EOF
test-line-buffer <<-\EOF >actual6 &&
0
5
foo
EOF
test_cmp expected1 actual1 &&
test_cmp expected2 actual2 &&
test_cmp expected3 actual3 &&
test_cmp expected4 actual4 &&
test_cmp expected5 actual5 &&
test_cmp expected6 actual6
'
test_expect_success 'string pool' '
echo a does not equal b >expected.differ &&
echo a equals a >expected.match &&
echo equals equals equals >expected.matchmore &&
test-string-pool "a,--b" >actual.differ &&
test-string-pool "a,a" >actual.match &&
test-string-pool "equals-equals" >actual.matchmore &&
test_must_fail test-string-pool a,a,a &&
test_must_fail test-string-pool a &&
test_cmp expected.differ actual.differ &&
test_cmp expected.match actual.match &&
test_cmp expected.matchmore actual.matchmore
'
test_expect_success 'treap sort' '
cat <<-\EOF >unsorted &&
68
12
13
13
68
13
13
21
10
11
12
13
13
EOF
sort unsorted >expected &&
test-treap <unsorted >actual &&
test_cmp expected actual
'
test_done
|