bsc/trie/iterator_test.go

34 lines
598 B
Go
Raw Normal View History

2015-01-08 12:47:04 +02:00
package trie
2014-11-19 16:05:08 +02:00
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"},
2014-11-19 16:05:08 +02:00
}
v := make(map[string]bool)
for _, val := range vals {
v[val.k] = false
trie.UpdateString(val.k, val.v)
}
trie.Commit()
2014-11-19 16:05:08 +02:00
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)
}
}
}