objtests

package
v0.0.0-...-c5d0b2b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestValues = [...]interface{}{

	nil,
	false,
	true,

	0,
	1,
	23,
	24,
	127,
	-1,
	-10,
	-31,
	-32,
	objutil.Int8Min,
	objutil.Int8Max + 1,
	objutil.Int8Min - 1,
	objutil.Int16Max,
	objutil.Int16Min,
	objutil.Int16Max + 1,
	objutil.Int16Min - 1,
	objutil.Int32Max,
	objutil.Int32Min,
	objutil.Int32Max + 1,
	objutil.Int32Min - 1,
	int64(objutil.Int64Max),
	int64(objutil.Int64Min),

	uint(0),
	uint(1),
	uint8(objutil.Uint8Max),
	uint16(objutil.Uint8Max) + 1,
	uint16(objutil.Uint16Max),
	uint32(objutil.Uint16Max) + 1,
	uint32(objutil.Uint32Max),
	uint64(objutil.Uint32Max) + 1,

	float32(0),
	float32(objutil.Float32IntMin),
	float32(objutil.Float32IntMax),
	float64(0),
	float64(0.5),

	"",
	"Hello World!",
	"Hello\"World!",
	"Hello\\World!",
	"Hello\nWorld!",
	"Hello\rWorld!",
	"Hello\tWorld!",
	"Hello\bWorld!",
	"Hello\fWorld!",
	"你好",
	strings.Repeat("A", 32),
	strings.Repeat("A", objutil.Uint8Max+1),
	strings.Repeat("A", objutil.Uint16Max+1),

	[]byte(""),
	[]byte("Hello World!"),
	bytes.Repeat([]byte("A"), objutil.Uint8Max+1),
	bytes.Repeat([]byte("A"), objutil.Uint16Max+1),

	time.Nanosecond,
	time.Microsecond,
	time.Millisecond,
	time.Second,
	time.Minute,
	time.Hour,

	time.Unix(0, 0).In(time.UTC),
	time.Unix(1, 42).In(time.UTC),
	time.Unix(17179869184, 999999999).In(time.UTC),
	time.Date(2016, 12, 20, 0, 20, 1, 0, time.UTC),

	errors.New(""),
	errors.New("Hello World!"),
	errors.New(strings.Repeat("A", objutil.Uint8Max+1)),
	errors.New(strings.Repeat("A", objutil.Uint16Max+1)),

	[]int{},
	[]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9},
	make([]int, objutil.Uint8Max+1),
	make([]int, objutil.Uint16Max+1),

	makeMap(0),
	makeMap(15),
	makeMap(objutil.Uint8Max + 1),
	makeMap(objutil.Uint16Max + 1),

	struct{}{},
	struct{ A int }{42},
	struct{ A, B, C int }{1, 2, 3},
	struct {
		A int
		T time.Time
		S string
	}{42, time.Date(2016, 12, 20, 0, 20, 1, 0, time.UTC), "Hello World!"},

	net.TCPAddr{
		IP:   net.ParseIP("::1"),
		Port: 4242,
		Zone: "zone",
	},
	net.UDPAddr{
		IP:   net.ParseIP("::1"),
		Port: 4242,
		Zone: "zone",
	},
	net.IPAddr{
		IP:   net.ParseIP("::1"),
		Zone: "zone",
	},
	net.IPv4(127, 0, 0, 1),

	parseURL("http://localhost:4242/hello/world?answer=42#question"),
	parseQuery("answer=42&message=Hello+World"),

	parseEmail("git@github.com"),
	parseEmailList("Alice <alice@example.com>, Bob <bob@example.com>, Eve <eve@example.com>"),
}

TestValues is an array of all the values used by the TestCodec suite.

Functions

func BenchmarkCodec

func BenchmarkCodec(b *testing.B, codec objconv.Codec)

BenchmarkCodec implements a benchmark suite for codecs, making it easy to get comparable performance results for various formats.

func TestCodec

func TestCodec(t *testing.T, codec objconv.Codec)

TestCodec implements a test suite for validating that a codec properly support encoding and decoding values of different types. The function also tests that the codec behaves properly when used with stream encoders and decoders.

Types

This section is empty.

Jump to

Keyboard shortcuts

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