(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func TestTrie_Insert(t *testing.T) { |
| 38 | trie := NewPatricia() |
| 39 | tests := []struct { |
| 40 | key string |
| 41 | value int32 |
| 42 | result bool |
| 43 | }{ |
| 44 | {"", 1, true}, |
| 45 | {"a", 2, true}, |
| 46 | {"aaa", 3, true}, |
| 47 | {"", 2, false}, |
| 48 | {"a", 919, false}, |
| 49 | {"ueqio19qwdada1", 21312, true}, |
| 50 | } |
| 51 | Convey("The value should be equal", t, func() { |
| 52 | for _, test := range tests { |
| 53 | var hashedKey []byte |
| 54 | if strings.Compare(test.key, "") == 0 { |
| 55 | hashedKey = hash.HashB([]byte{}) |
| 56 | } else { |
| 57 | hashedKey = hash.HashB(serialize(test.key)) |
| 58 | } |
| 59 | result := trie.Insert(hashedKey, serialize(test.value)) |
| 60 | So(result, ShouldEqual, test.result) |
| 61 | } |
| 62 | }) |
| 63 | } |
| 64 | |
| 65 | func TestTrie_Get(t *testing.T) { |
| 66 | trie := NewPatricia() |
nothing calls this directly
no test coverage detected