@@ -144,10 +144,11 @@ func TestInsert(t *testing.T) {
144144
145145func TestFind (t * testing.T ) {
146146 tests := []struct {
147- name string
148- value string
149- trie Trie
150- found bool
147+ name string
148+ value string
149+ trie Trie
150+ found bool
151+ isLeaf bool
151152 }{
152153 {
153154 name : "find nonexistent element in trie" ,
@@ -157,7 +158,8 @@ func TestFind(t *testing.T) {
157158 children : []* node {
158159 {value : "omane" , childCount : 0 }},
159160 childCount : 1 }}, count : 1 },
160- found : false ,
161+ found : false ,
162+ isLeaf : false ,
161163 },
162164 {
163165 name : "find existing element in trie" ,
@@ -167,7 +169,8 @@ func TestFind(t *testing.T) {
167169 children : []* node {
168170 {value : "omane" , childCount : 0 }},
169171 childCount : 1 }}, count : 1 },
170- found : true ,
172+ found : true ,
173+ isLeaf : true ,
171174 },
172175 {
173176 name : "find trimmed existing element in trie" ,
@@ -177,7 +180,8 @@ func TestFind(t *testing.T) {
177180 children : []* node {
178181 {value : "omane" , childCount : 0 }},
179182 childCount : 1 }}, count : 1 },
180- found : true ,
183+ found : true ,
184+ isLeaf : true ,
181185 },
182186 {
183187 name : "find existing element in trie with two elements" ,
@@ -188,7 +192,8 @@ func TestFind(t *testing.T) {
188192 children : []* node {{value : "e" , childCount : 0 },
189193 {value : "us" , childCount : 0 }},
190194 childCount : 2 }}, childCount : 1 }}, count : 2 },
191- found : true ,
195+ found : true ,
196+ isLeaf : true ,
192197 },
193198 {
194199 name : "find existing second element in trie with two elements" ,
@@ -199,7 +204,8 @@ func TestFind(t *testing.T) {
199204 children : []* node {{value : "e" , childCount : 0 },
200205 {value : "us" , childCount : 0 }},
201206 childCount : 2 }}, childCount : 1 }}, count : 2 },
202- found : true ,
207+ found : true ,
208+ isLeaf : true ,
203209 },
204210 {
205211 name : "find existing element in trie with three elements" ,
@@ -212,7 +218,8 @@ func TestFind(t *testing.T) {
212218 {value : "us" , childCount : 0 }},
213219 childCount : 2 },
214220 {value : "ulus" , childCount : 0 }}, childCount : 2 }}, childCount : 1 }}, count : 3 },
215- found : true ,
221+ found : true ,
222+ isLeaf : true ,
216223 },
217224 {
218225 name : "find existing second element in trie with three elements" ,
@@ -225,7 +232,8 @@ func TestFind(t *testing.T) {
225232 {value : "us" , childCount : 0 }},
226233 childCount : 2 },
227234 {value : "ulus" , childCount : 0 }}, childCount : 2 }}, childCount : 1 }}, count : 3 },
228- found : true ,
235+ found : true ,
236+ isLeaf : true ,
229237 },
230238 {
231239 name : "find existing third element in trie with three elements" ,
@@ -238,7 +246,8 @@ func TestFind(t *testing.T) {
238246 {value : "us" , childCount : 0 }},
239247 childCount : 2 },
240248 {value : "ulus" , childCount : 0 }}, childCount : 2 }}, childCount : 1 }}, count : 3 },
241- found : true ,
249+ found : true ,
250+ isLeaf : true ,
242251 },
243252 {
244253 name : "find existing fourth element in trie with four elements" ,
@@ -252,7 +261,8 @@ func TestFind(t *testing.T) {
252261 childCount : 2 },
253262 {value : "ulus" , childCount : 0 }}},
254263 {value : "ubens" , childCount : 0 }}, childCount : 1 }}, count : 4 },
255- found : true ,
264+ found : true ,
265+ isLeaf : true ,
256266 },
257267 {
258268 name : "find existing fifth element in trie with five elements" ,
@@ -269,7 +279,8 @@ func TestFind(t *testing.T) {
269279 children : []* node {{value : "ns" , childCount : 0 },
270280 {value : "r" , childCount : 0 }},
271281 childCount : 2 }}, childCount : 1 }}, count : 5 },
272- found : true ,
282+ found : true ,
283+ isLeaf : true ,
273284 },
274285 {
275286 name : "find existing sixth element in trie with six elements" ,
@@ -288,7 +299,8 @@ func TestFind(t *testing.T) {
288299 {value : "r" , childCount : 0 }}, childCount : 2 },
289300 {value : "icon" , childCount : 0 }}, childCount : 2 }},
290301 childCount : 1 }}, count : 6 },
291- found : true ,
302+ found : true ,
303+ isLeaf : true ,
292304 },
293305 {
294306 name : "find existing sixth element in trie with seven elements" ,
@@ -310,7 +322,8 @@ func TestFind(t *testing.T) {
310322 {value : "undus" , childCount : 0 }},
311323 childCount : 2 }},
312324 childCount : 2 }}, childCount : 1 }}, count : 7 },
313- found : true ,
325+ found : true ,
326+ isLeaf : true ,
314327 },
315328 {
316329 name : "find existing seventh element in trie with seven elements" ,
@@ -332,7 +345,8 @@ func TestFind(t *testing.T) {
332345 {value : "undus" , childCount : 0 }},
333346 childCount : 2 }},
334347 childCount : 2 }}, childCount : 1 }}, count : 7 },
335- found : true ,
348+ found : true ,
349+ isLeaf : true ,
336350 },
337351 }
338352
@@ -341,5 +355,12 @@ func TestFind(t *testing.T) {
341355 if found != test .found {
342356 t .Errorf ("test '%s': expected found to be %t" , test .name , test .found )
343357 }
358+ /*
359+ if found {
360+ if isLeaf != test.isLeaf {
361+ t.Errorf("test '%s': expected isLeaf to be %t", test.name, test.isLeaf)
362+ }
363+ }
364+ */
344365 }
345366}
0 commit comments