github.com/jonasnick/go-ethereum@v0.7.12-0.20150216215225-22176f05d387/trie/iterator_test.go (about) 1 package trie 2 3 import "testing" 4 5 func TestIterator(t *testing.T) { 6 trie := NewEmpty() 7 vals := []struct{ k, v string }{ 8 {"do", "verb"}, 9 {"ether", "wookiedoo"}, 10 {"horse", "stallion"}, 11 {"shaman", "horse"}, 12 {"doge", "coin"}, 13 {"dog", "puppy"}, 14 {"somethingveryoddindeedthis is", "myothernodedata"}, 15 } 16 v := make(map[string]bool) 17 for _, val := range vals { 18 v[val.k] = false 19 trie.UpdateString(val.k, val.v) 20 } 21 trie.Commit() 22 23 it := trie.Iterator() 24 for it.Next() { 25 v[string(it.Key)] = true 26 } 27 28 for k, found := range v { 29 if !found { 30 t.Error("iterator didn't find", k) 31 } 32 } 33 }