blob: c1a6c7d16a314366625c3b8245410a13f6524401 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package main
import (
"testing"
_"fmt"
)
func TestTriePut(t *testing.T) {
db, err := NewDatabase()
defer db.Close()
if err != nil {
t.Error("Error starting db")
}
key := db.trie.Put([]byte("testing node"))
data, err := db.db.Get(key, nil)
if err != nil {
t.Error("Nothing at node")
}
s, _ := Decode(data, 0)
if str, ok := s.([]byte); ok {
if string(str) != "testing node" {
t.Error("Wrong value node", str)
}
} else {
t.Error("Invalid return type")
}
}
func TestTrieUpdate(t *testing.T) {
db, err := NewDatabase()
defer db.Close()
if err != nil {
t.Error("Error starting db")
}
db.trie.Update("test", "test")
}
|