MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / TestTrie_Insert

Function TestTrie_Insert

merkle/patriciatrie_test.go:37–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func 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
65func TestTrie_Get(t *testing.T) {
66 trie := NewPatricia()

Callers

nothing calls this directly

Calls 4

HashBFunction · 0.92
NewPatriciaFunction · 0.85
serializeFunction · 0.85
InsertMethod · 0.80

Tested by

no test coverage detected