mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 04:57:17 +00:00
34 lines
598 B
Go
34 lines
598 B
Go
package trie
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|