example_test.gno
0.82 Kb · 43 lines
1package bptree
2
3// ExampleNew shows NewBPTree32() and adding a value
4func ExampleNew() {
5 var tree *BPTree
6 tree = NewBPTree32()
7 tree.Set("key0", "value0")
8
9 var updated bool
10 updated = tree.Set("key1", "value1")
11 println(updated, tree.Size())
12
13 // Output:
14 // false 2
15}
16
17// ExampleUpdate shows NewBPTree32() and updating a value
18func ExampleUpdate() {
19 var tree *BPTree
20 tree = NewBPTree32()
21 tree.Set("key0", "value0")
22
23 var updated bool
24 updated = tree.Set("key0", "new_value0")
25 println(updated, tree.Size())
26
27 // Output:
28 // true 1
29}
30
31// ExampleZeroValue shows updating the zero value of a BPTree without NewBPTree32()
32func ExampleZeroValue() {
33 var tree BPTree
34 tree.Set("key0", "value0")
35 tree.Set("key1", "value1")
36
37 var updated bool
38 updated = tree.Set("key2", "value2")
39 println(updated, tree.Size())
40
41 // Output:
42 // false 3
43}