Added new iterator and tests

This commit is contained in:
obscuren
2014-11-19 15:05:08 +01:00
parent 14e2e488fd
commit e70529a977
6 changed files with 160 additions and 11 deletions

28
ptrie/iterator_test.go Normal file
View File

@ -0,0 +1,28 @@
package ptrie
import "testing"
func TestIterator(t *testing.T) {
trie := NewEmpty()
vals := []struct{ k, v string }{
{"do", "verb"},
{"ether", "wookiedoo"},
{"horse", "stallion"},
}
v := make(map[string]bool)
for _, val := range vals {
v[val.k] = false
trie.UpdateString(val.k, val.v)
}
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)
}
}
}