diff options
author | obscuren <geffobscura@gmail.com> | 2014-11-19 22:05:08 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-11-19 22:05:08 +0800 |
commit | e70529a97785012368e7e0d5b272cccab705e551 (patch) | |
tree | ee74d588bda2352d0026f179f2e7a9e8c210e57b /ptrie/iterator_test.go | |
parent | 14e2e488fdf0f4d6ed1a5a48ffbbe883faa7edb6 (diff) | |
download | dexon-e70529a97785012368e7e0d5b272cccab705e551.tar.gz dexon-e70529a97785012368e7e0d5b272cccab705e551.tar.zst dexon-e70529a97785012368e7e0d5b272cccab705e551.zip |
Added new iterator and tests
Diffstat (limited to 'ptrie/iterator_test.go')
-rw-r--r-- | ptrie/iterator_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ptrie/iterator_test.go b/ptrie/iterator_test.go new file mode 100644 index 000000000..8921bb670 --- /dev/null +++ b/ptrie/iterator_test.go @@ -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) + } + } +} |