mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
599 B
33 lines
599 B
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)
|
|
}
|
|
}
|
|
}
|
|
|