aboutsummaryrefslogblamecommitdiffstats
path: root/ptrie/iterator_test.go
blob: acfc03d63371d5044584b31cdf93e614aea3e0b2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                        



                                                                     





                                               
                     











                                                          
package ptrie

import "testing"

func TestIterator(t *testing.T) {
    trie := NewEmpty()
    vals := []struct{ k, v string }{
        {"do", "verb"},
        {"ether", "wookiedoo"},
        {"horse", "stallion"},
        {"shaman", "horse"},
        {"doge", "coin"},
        {"dog", "puppy"},
        {"somethingveryoddindeedthis is", "myothernodedata"},
    }
    v := make(map[string]bool)
    for _, val := range vals {
        v[val.k] = false
        trie.UpdateString(val.k, val.v)
    }
    trie.Commit()

    it := trie.Iterator()
    for it.Next() {
        v[string(it.Key)] = true
    }

    for k, found := range v {
        if !found {
            t.Error("iterator didn't find", k)
        }
    }
}