tests

package
v0.0.0-...-5c34657 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConstantInt    int    = 8
	ConstantInt8   int8   = 8
	ConstantInt16  int16  = 8
	ConstantInt32  int32  = 8
	ConstantInt64  int64  = 8
	ConstantUint   uint   = 8
	ConstantUint8  uint8  = 8
	ConstantUint16 uint16 = 8
	ConstantUint32 uint32 = 8
	ConstantUint64 uint64 = 8
)

Ensure all different widths of integer can be used as constant keys.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliasContainer

type AliasContainer struct {
	Fast FastAlias
}

AliasContainer wraps a FastAlias.

type ArrayConstants

type ArrayConstants struct {
	ConstantInt    [ConstantInt]string
	ConstantInt8   [ConstantInt8]string
	ConstantInt16  [ConstantInt16]string
	ConstantInt32  [ConstantInt32]string
	ConstantInt64  [ConstantInt64]string
	ConstantUint   [ConstantUint]string
	ConstantUint8  [ConstantUint8]string
	ConstantUint16 [ConstantUint16]string
	ConstantUint32 [ConstantUint32]string
	ConstantUint64 [ConstantUint64]string
	ConstantHex    [0x16]string
	ConstantOctal  [07]string
}

type Block

type Block [32]byte

type ConvertErr

type ConvertErr struct {
	Err ConvertErrVal
}

type ConvertErrVal

type ConvertErrVal string

type ConvertIntf

type ConvertIntf struct {
	Intf ConvertIntfVal
}

type ConvertIntfVal

type ConvertIntfVal struct {
	Test string
}

type ConvertString

type ConvertString struct {
	String ConvertStringVal
}

type ConvertStringMapValue

type ConvertStringMapValue struct {
	Strings map[string]ConvertStringVal
}

type ConvertStringSlice

type ConvertStringSlice struct {
	Strings []ConvertStringVal
}

type ConvertStringVal

type ConvertStringVal string

type Custom

type Custom struct {
	Bts   CustomBytes          `msgp:"bts"`
	Mp    map[string]*Embedded `msgp:"mp"`
	Enums []MyEnum             `msgp:"enums"` // test explicit enum shim
	Some  FileHandle           `msgp:"file_handle"`
}

type CustomBytes

type CustomBytes []byte

type CustomInt

type CustomInt int

type Embedded

type Embedded struct {
	*Embedded   // Test an embedded field.
	Children    []Embedded
	PtrChildren []*Embedded
	Other       string
}

Embedded has a recursive pointer.

type EmptyStruct

type EmptyStruct struct{}

type EmptyStructMapUsesTuple

type EmptyStructMapUsesTuple struct {
	Nested    EmptyStructTuple
	NestedPtr *EmptyStructTuple
}

type EmptyStructNested

type EmptyStructNested struct {
	A int
	X struct{}
	Y struct{}
	Z int
}

type EmptyStructTuple

type EmptyStructTuple struct{}

type EmptyStructTupleNested

type EmptyStructTupleNested struct {
	A int
	X struct{}
	Y struct{}
	Z int
}

type EmptyStructTupleUsesMap

type EmptyStructTupleUsesMap struct {
	Nested    EmptyStruct
	NestedPtr *EmptyStruct
}

type EmptyStructTupleUsesTuple

type EmptyStructTupleUsesTuple struct {
	Nested    EmptyStructTuple
	NestedPtr *EmptyStructTuple
}

type EmptyStructUses

type EmptyStructUses struct {
	Nested    EmptyStruct
	NestedPtr *EmptyStruct
}

type FastAlias

type FastAlias TestFast

FastAlias tests nested aliases.

type FileHandle

type FileHandle struct {
	Relevant Files  `msgp:"files"`
	Name     string `msgp:"name"`
}

type Files

type Files []*os.File

type Fixed

type Fixed struct {
	A float64
	B bool
}

Fixed tests fixed-size structs.

type Insane

type Insane [3]map[string]struct{ A, B CustomInt }

type Int32ForUint16Dec

type Int32ForUint16Dec int32

Int32ForUint16Dec values should be decodable from an encoded Uint16Enc.

type IntA

type IntA int

Test dependency resolution

type IntB

type IntB IntA

type IntC

type IntC IntB

type MixedIntsDec

type MixedIntsDec struct {
	A int64 // Keeping same as above (like in real world).
	B int8
	C int32
	D int64
}

MixedIntsDec values should be decodable from an encoded MixedIntsEnc.

type MixedIntsEnc

type MixedIntsEnc struct {
	A int64
	B uint8
	C int32
	D uint64
}

MixedIntsEnc values should be decodable into a MixedInts1dec (if no integers overflow or are negative).

type MyEnum

type MyEnum byte
const (
	A MyEnum = iota
	B
	C
	D
)

func (MyEnum) String

func (m MyEnum) String() string

type NoFields

type NoFields struct {
	Func func(string) error
	// contains filtered or unexported fields
}

NoFields gets methods generated, but it does not have any fields that can get encoded or decoded with MessagePack.

This tests whether a "field" variable declaration is made in unmarshal or decode methods for a struct with no encodable/decodable fields. If an unused "field" variable is declared, the code will not compile.

type NonMsgpTags

type NonMsgpTags struct {
	A      []string `json:"fooJSON" msg:"fooMsgp"`
	B      string   `json:"barJSON"`
	C      []string `json:"bazJSON" msg:"-"`
	Nested []struct {
		A          []string `json:"a"`
		B          string   `json:"b"`
		C          []string `json:"c"`
		VeryNested []struct {
			A []string `json:"a"`
			B []string `msgp:"bbbb" xml:"-"`
		}
	}
}

NonMsgpTags tests that non-msgp struct field tags work.

type Object

type Object struct {
	ObjectNo string   `msgp:"objno"`
	Slice1   []string `msgp:"slice1"`
	Slice2   []string `msgp:"slice2"`
	MapMap   map[string]map[string]string
}

type SpecialID

type SpecialID string

type T

type T struct {
	T time.Time
}

T represents a type that we'll be shimming.

type TestBench

type TestBench struct {
	Name     string
	BirthDay time.Time
	Phone    string
	Siblings int
	Spouse   bool
	Money    float64
}

type TestFast

type TestFast struct {
	Lat, Long, Alt float64 // inline declaration
	Data           []byte
}

type TestHidden

type TestHidden struct {
	A   string
	B   []float64
	Bad func(string) bool // This results in a warning: field "Bad" unsupported
}

TestHidden has an ignored field.

type TestObj

type TestObj struct{ ID1, ID2 SpecialID }

type TestType

type TestType struct {
	F   *float64          `msgp:"float"`
	Els map[string]string `msgp:"elements"`
	Obj struct {
		ValueA string `msgp:"value_a"`
		ValueB []byte `msgp:"value_b"`
	} `msgp:"object"`
	Child      *TestType   `msgp:"child"`
	Time       time.Time   `msgp:"time"`
	Any        interface{} `msgp:"any"`
	Appended   msgp.Raw    `msgp:"appended"`
	Num        msgp.Number `msgp:"num"`
	Byte       byte
	Rune       rune
	RunePtr    *rune
	RunePtrPtr **rune
	RuneSlice  []rune
	Slice1     []string
	Slice2     []string
	SlicePtr   *[]string
}

TestType tests various kinds of types.

type Things

type Things struct {
	Cmplx complex64                         `msgp:"complex"` // test slices
	Vals  []int32                           `msgp:"values"`
	Arr   [msgp.ExtensionPrefixSize]float64 `msgp:"arr"`            // test const array and *ast.SelectorExpr as array size
	Arr2  [4]float64                        `msgp:"arr2"`           // test basic lit array
	Ext   *msgp.RawExtension                `msgp:"ext,extension"`  // test extension
	Oext  msgp.RawExtension                 `msgp:"oext,extension"` // test extension reference
}

Things has a few interesting things.

type Tree

type Tree struct {
	Children []Tree
	Element  int
	Parent   *Wrapper
}

type Uint16Enc

type Uint16Enc uint16

Uint16Enc values should be decodable into a Int32ForUint16Dec (if no integers overflow or are negative).

type Wrapper

type Wrapper struct {
	Tree *Tree
}

type X

type X struct {
	Values    [32]byte    // should compile to 32*msgp.ByteSize; encoded as Bin
	ValuesPtr *[32]byte   // check (*)[:] deref
	More      Block       // should be identical to the above
	Others    [][32]int32 // should compile to len(x.Others)*32*msgp.Int32Size
	Matrix    [][]int32   // should not optimize
	ManyFixed []Fixed
}

X tests edge-cases with compiling size compilation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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