Skip to content

Commit ffd8d88

Browse files
committed
test: DatabaseStat example output
1 parent 5670032 commit ffd8d88

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

core/rawdb/database.libevm_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package rawdb_test
1818

1919
import (
20+
"fmt"
21+
2022
"github.com/ava-labs/libevm/common"
2123
// To ensure that all methods are available to importing packages, this test
2224
// is defined in package `rawdb_test` instead of `rawdb`.
@@ -26,15 +28,17 @@ import (
2628
// ExampleDatabaseStat demonstrates the method signatures of DatabaseStat, which
2729
// exposes an otherwise unexported type that won't have its methods documented.
2830
func ExampleDatabaseStat() {
29-
var (
30-
stat rawdb.DatabaseStat
31-
size common.StorageSize
32-
)
31+
var stat rawdb.DatabaseStat
32+
33+
stat.Add(common.StorageSize(0)) // only to demonstrate param type
34+
stat.Add(1)
35+
stat.Add(2)
36+
stat.Add(4)
3337

34-
stat.Add(size)
38+
fmt.Println("Sum:", stat.Size()) // sum of all values passed to Add()
39+
fmt.Println("Count:", stat.Count()) // number of calls to Add()
3540

36-
var (
37-
_ string = stat.Size() // sum of all values passed to Add()
38-
_ string = stat.Count() // number of calls to Add()
39-
)
41+
// Output:
42+
// Sum: 7.00 B
43+
// Count: 4
4044
}

0 commit comments

Comments
 (0)