@@ -341,113 +341,6 @@ func TestPrefixTraversalWords(t *testing.T) {
341341 assert .Equal (t , expected , found )
342342}
343343
344- func TestPrefixTraversalDescWords (t * testing.T ) {
345- t .Parallel ()
346-
347- var found []string
348-
349- tree , _ := treeWithData ("test/assets/words.txt" )
350- tree .ForEachPrefix (Key ("antisa" ), func (node Node ) bool {
351- if node .Kind () == Leaf {
352- val , ok := node .Value ().([]byte )
353- assert .True (t , ok )
354-
355- found = append (found , string (val ))
356- }
357-
358- return true
359- }, TraverseReverse )
360-
361- expected := []string {
362- "antisavage" ,
363- "antisalooner" ,
364- "antisaloon" ,
365- "antisacerdotalist" ,
366- "antisacerdotal" ,
367- }
368- assert .Equal (t , expected , found )
369- }
370-
371- func TestTraversalForEachWordsBothDirections (t * testing.T ) {
372- t .Parallel ()
373-
374- var (
375- asc []string
376- desc []string
377- )
378-
379- tree , _ := treeWithData ("test/assets/words.txt" )
380- tree .ForEach (func (node Node ) bool {
381- val , ok := node .Value ().([]byte )
382- assert .True (t , ok )
383-
384- asc = append (asc , string (val ))
385-
386- return true
387- })
388- assert .Len (t , asc , 235886 )
389-
390- tree .ForEach (func (node Node ) bool {
391- val , ok := node .Value ().([]byte )
392- assert .True (t , ok )
393-
394- desc = append (desc , string (val ))
395-
396- return true
397- }, TraverseReverse )
398- assert .Len (t , desc , 235886 )
399-
400- assert .True (t , areReversedCopies (asc , desc ))
401- }
402-
403- func TestTraversalIteratorWordsBothDirections (t * testing.T ) {
404- t .Parallel ()
405-
406- var (
407- asc []string
408- desc []string
409- )
410-
411- tree , _ := treeWithData ("test/assets/words.txt" )
412- iterateWithCallback (tree .Iterator (), func (node Node ) bool {
413- val , ok := node .Value ().([]byte )
414- assert .True (t , ok )
415-
416- asc = append (asc , string (val ))
417-
418- return true
419- })
420- assert .Len (t , asc , 235886 )
421-
422- iterateWithCallback (tree .Iterator (TraverseReverse ), func (node Node ) bool {
423- val , ok := node .Value ().([]byte )
424- assert .True (t , ok )
425-
426- desc = append (desc , string (val ))
427-
428- return true
429- })
430- assert .Len (t , desc , 235886 )
431-
432- assert .True (t , areReversedCopies (asc , desc ))
433- }
434-
435- // areReversedCopies returns true if lhs and rhs are reversed copies of each other.
436- func areReversedCopies (lhs , rhs []string ) bool {
437- if len (lhs ) != len (rhs ) {
438- return false
439- }
440-
441- n := len (lhs )
442- for i := 0 ; i < n ; i ++ {
443- if lhs [i ] != rhs [n - i - 1 ] {
444- return false
445- }
446- }
447-
448- return true
449- }
450-
451344func TestTreeIterator (t * testing.T ) {
452345 t .Parallel ()
453346
0 commit comments