testutil

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

Codecs we want to test.

View Source
var DbInitalizer = []func(db.Codec) db.DB{
	func(codec db.Codec) db.DB {
		return memdb.New(codec)
	},
	func(codec db.Codec) db.DB {
		return leveldb.New(".leveldb", codec)
	},
	func(codec db.Codec) db.DB {
		return badgerdb.New(".badgerdb", codec)
	},
}

DbInitalizer returns a list of initialize functions of different DB implementations.

Functions

func CheckErrors

func CheckErrors(errs []error) error

CheckErrors takes a list of errors and check if any of them is not nil. It returns the first non-nil error or nil if all of the errors are nil.

func RandomNonDupStrings

func RandomNonDupStrings(i int) []string

RandomNonDupStrings returns a list of non-duplicate strings.

func RandomTestStructGroups

func RandomTestStructGroups(group, entriesPerGroup int) [][]TestStruct

RandomTestStructGroups creates a group of random TestStructs.

Types

type TestStruct

type TestStruct struct {
	A string
	B int
	C bool
	D []byte
	E map[string]float64
}

TestStruct is a struct which includes some commonly used types.

func RandomTestStruct

func RandomTestStruct() TestStruct

RandomTestStruct returns a random `TestStruct`

func (TestStruct) MarshalBinary added in v1.0.3

func (s TestStruct) MarshalBinary() ([]byte, error)

MarshalBinary implements the `BinaryMarshaler` interface.

func (*TestStruct) UnmarshalBinary added in v1.0.3

func (s *TestStruct) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the `BinaryUnmarshaler` interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL