diff options
author | obscuren <geffobscura@gmail.com> | 2014-02-20 21:40:00 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-02-20 21:40:00 +0800 |
commit | 9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d (patch) | |
tree | fe713e30b9f4d9b7602b12726800918a7ff5efc4 /ethutil/trie_test.go | |
parent | 4afb624c450229b5f0a3554d13de35fd2db8f682 (diff) | |
download | go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar.gz go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar.bz2 go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar.lz go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar.xz go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.tar.zst go-tangerine-9bc5c4a0c5116cf3b49a55fc2aceb5f5c3b3e34d.zip |
Long over due Trie delete implemented
Diffstat (limited to 'ethutil/trie_test.go')
-rw-r--r-- | ethutil/trie_test.go | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/ethutil/trie_test.go b/ethutil/trie_test.go index fa60c8cfc..9d2c8e19f 100644 --- a/ethutil/trie_test.go +++ b/ethutil/trie_test.go @@ -1,8 +1,7 @@ package ethutil import ( - _ "encoding/hex" - _ "fmt" + "reflect" "testing" ) @@ -116,3 +115,36 @@ func TestTrieCmp(t *testing.T) { t.Errorf("Expected tries not to be equal %x %x", trie1.Root, trie2.Root) } } + +func TestTrieDelete(t *testing.T) { + _, trie := New() + trie.Update("cat", LONG_WORD) + exp := trie.Root + trie.Update("dog", LONG_WORD) + trie.Delete("dog") + if !reflect.DeepEqual(exp, trie.Root) { + t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root) + } + + trie.Update("dog", LONG_WORD) + exp = trie.Root + trie.Update("dude", LONG_WORD) + trie.Delete("dude") + if !reflect.DeepEqual(exp, trie.Root) { + t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root) + } +} + +func TestTrieDeleteWithValue(t *testing.T) { + _, trie := New() + trie.Update("c", LONG_WORD) + exp := trie.Root + trie.Update("ca", LONG_WORD) + trie.Update("cat", LONG_WORD) + trie.Delete("ca") + trie.Delete("cat") + if !reflect.DeepEqual(exp, trie.Root) { + t.Errorf("Expected tries to be equal %x : %x", exp, trie.Root) + } + +} |