Documentation ¶
Overview ¶
Package codec is a generated GoMock package.
Index ¶
- Variables
- func TestArray(codec GeneralCodec, t testing.TB)
- func TestArrayOfInterface(codec GeneralCodec, t testing.TB)
- func TestBigArray(codec GeneralCodec, t testing.TB)
- func TestBool(codec GeneralCodec, t testing.TB)
- func TestEmptySliceSerialization(codec GeneralCodec, t testing.TB)
- func TestExtraSpace(codec GeneralCodec, t testing.TB)
- func TestInterface(codec GeneralCodec, t testing.TB)
- func TestMaxSizeSlice(codec GeneralCodec, t testing.TB)
- func TestMultipleTags(codec GeneralCodec, t testing.TB)
- func TestNegativeNumbers(codec GeneralCodec, t testing.TB)
- func TestNilSlice(codec GeneralCodec, t testing.TB)
- func TestNilSliceSerialization(codec GeneralCodec, t testing.TB)
- func TestPointerToInterface(codec GeneralCodec, t testing.TB)
- func TestPointerToStruct(codec GeneralCodec, t testing.TB)
- func TestRegisterStructTwice(codec GeneralCodec, t testing.TB)
- func TestRestrictedSlice(codec GeneralCodec, t testing.TB)
- func TestSerializeOfNoSerializeField(codec GeneralCodec, t testing.TB)
- func TestSerializeUnexportedField(codec GeneralCodec, t testing.TB)
- func TestSlice(codec GeneralCodec, t testing.TB)
- func TestSliceLengthOverflow(codec GeneralCodec, t testing.TB)
- func TestSliceOfInterface(codec GeneralCodec, t testing.TB)
- func TestSliceOfStruct(codec GeneralCodec, t testing.TB)
- func TestSliceTooLarge(codec GeneralCodec, t testing.TB)
- func TestSliceWithEmptySerialization(codec GeneralCodec, t testing.TB)
- func TestSliceWithEmptySerializationOutOfMemory(codec GeneralCodec, t testing.TB)
- func TestString(codec GeneralCodec, t testing.TB)
- func TestStruct(codec GeneralCodec, t testing.TB)
- func TestTooLargeUnmarshal(codec GeneralCodec, t testing.TB)
- func TestUInt32(codec GeneralCodec, t testing.TB)
- func TestUIntPtr(codec GeneralCodec, t testing.TB)
- func TestUnmarshalInvalidInterface(codec GeneralCodec, t testing.TB)
- type Codec
- type Foo
- type GeneralCodec
- type Manager
- type MockManager
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) Marshal(arg0 uint16, arg1 interface{}) ([]byte, error)
- func (m *MockManager) RegisterCodec(arg0 uint16, arg1 Codec) error
- func (m *MockManager) Size(arg0 uint16, arg1 interface{}) (int, error)
- func (m *MockManager) Unmarshal(arg0 []byte, arg1 interface{}) (uint16, error)
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) Marshal(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) RegisterCodec(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) Size(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockManagerMockRecorder) Unmarshal(arg0, arg1 interface{}) *gomock.Call
- type MultipleVersionsStruct
- type MyInnerStruct
- type MyInnerStruct2
- type MyInnerStruct3
- type Registry
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnsupportedType = errors.New("unsupported type") ErrMaxSliceLenExceeded = errors.New("max slice length exceeded") ErrDoesNotImplementInterface = errors.New("does not implement interface") ErrUnexportedField = errors.New("unexported field") ErrExtraSpace = errors.New("trailing buffer space") )
var ( ErrUnknownVersion = errors.New("unknown codec version") ErrMarshalNil = errors.New("can't marshal nil pointer or interface") ErrUnmarshalNil = errors.New("can't unmarshal nil") ErrUnmarshalTooBig = errors.New("byte array exceeds maximum length") ErrCantPackVersion = errors.New("couldn't pack codec version") ErrCantUnpackVersion = errors.New("couldn't unpack codec version") ErrDuplicatedVersion = errors.New("duplicated codec version") )
var ErrDuplicateType = errors.New("duplicate type registration")
var MultipleTagsTests = []func(c GeneralCodec, t testing.TB){ TestMultipleTags, }
var Tests = []func(c GeneralCodec, t testing.TB){ TestStruct, TestRegisterStructTwice, TestUInt32, TestUIntPtr, TestSlice, TestMaxSizeSlice, TestBool, TestArray, TestBigArray, TestPointerToStruct, TestSliceOfStruct, TestInterface, TestSliceOfInterface, TestArrayOfInterface, TestPointerToInterface, TestString, TestNilSlice, TestSerializeUnexportedField, TestSerializeOfNoSerializeField, TestNilSliceSerialization, TestEmptySliceSerialization, TestSliceWithEmptySerialization, TestSliceWithEmptySerializationOutOfMemory, TestSliceTooLarge, TestNegativeNumbers, TestTooLargeUnmarshal, TestUnmarshalInvalidInterface, TestRestrictedSlice, TestExtraSpace, TestSliceLengthOverflow, }
Functions ¶
func TestArrayOfInterface ¶
func TestArrayOfInterface(codec GeneralCodec, t testing.TB)
Test marshalling an array of interfaces
func TestBigArray ¶
func TestBigArray(codec GeneralCodec, t testing.TB)
Test marshalling a really big array
func TestEmptySliceSerialization ¶
func TestEmptySliceSerialization(codec GeneralCodec, t testing.TB)
Test marshaling a slice that has 0 elements (but isn't nil)
func TestExtraSpace ¶
func TestExtraSpace(codec GeneralCodec, t testing.TB)
Test unmarshaling something with extra data
func TestInterface ¶
func TestInterface(codec GeneralCodec, t testing.TB)
Test marshalling an interface
func TestMaxSizeSlice ¶
func TestMaxSizeSlice(codec GeneralCodec, t testing.TB)
Test marshalling/unmarshalling largest possible slice
func TestMultipleTags ¶
func TestMultipleTags(codec GeneralCodec, t testing.TB)
func TestNegativeNumbers ¶
func TestNegativeNumbers(codec GeneralCodec, t testing.TB)
Ensure serializing structs with negative number members works
func TestNilSlice ¶
func TestNilSlice(codec GeneralCodec, t testing.TB)
Ensure a nil slice is unmarshaled to slice with length 0
func TestNilSliceSerialization ¶
func TestNilSliceSerialization(codec GeneralCodec, t testing.TB)
Test marshalling of nil slice
func TestPointerToInterface ¶
func TestPointerToInterface(codec GeneralCodec, t testing.TB)
Test marshalling a pointer to an interface
func TestPointerToStruct ¶
func TestPointerToStruct(codec GeneralCodec, t testing.TB)
Test marshalling a pointer to a struct
func TestRegisterStructTwice ¶
func TestRegisterStructTwice(codec GeneralCodec, t testing.TB)
func TestRestrictedSlice ¶
func TestRestrictedSlice(codec GeneralCodec, t testing.TB)
Ensure deserializing slices that have been length restricted errors correctly
func TestSerializeOfNoSerializeField ¶
func TestSerializeOfNoSerializeField(codec GeneralCodec, t testing.TB)
func TestSerializeUnexportedField ¶
func TestSerializeUnexportedField(codec GeneralCodec, t testing.TB)
Ensure that trying to serialize a struct with an unexported member that has `serialize:"true"` returns error
func TestSlice ¶
func TestSlice(codec GeneralCodec, t testing.TB)
func TestSliceLengthOverflow ¶
func TestSliceLengthOverflow(codec GeneralCodec, t testing.TB)
Ensure deserializing slices that have been length restricted errors correctly
func TestSliceOfInterface ¶
func TestSliceOfInterface(codec GeneralCodec, t testing.TB)
Test marshalling a slice of interfaces
func TestSliceOfStruct ¶
func TestSliceOfStruct(codec GeneralCodec, t testing.TB)
Test marshalling a slice of structs
func TestSliceTooLarge ¶
func TestSliceTooLarge(codec GeneralCodec, t testing.TB)
func TestSliceWithEmptySerialization ¶
func TestSliceWithEmptySerialization(codec GeneralCodec, t testing.TB)
Test marshaling slice that is not nil and not empty
func TestSliceWithEmptySerializationOutOfMemory ¶
func TestSliceWithEmptySerializationOutOfMemory(codec GeneralCodec, t testing.TB)
func TestStruct ¶
func TestStruct(codec GeneralCodec, t testing.TB)
Test marshaling/unmarshaling a complicated struct
func TestTooLargeUnmarshal ¶
func TestTooLargeUnmarshal(codec GeneralCodec, t testing.TB)
Ensure deserializing structs with too many bytes errors correctly
func TestUInt32 ¶
func TestUInt32(codec GeneralCodec, t testing.TB)
func TestUIntPtr ¶ added in v1.9.5
func TestUIntPtr(codec GeneralCodec, t testing.TB)
func TestUnmarshalInvalidInterface ¶
func TestUnmarshalInvalidInterface(codec GeneralCodec, t testing.TB)
Ensure deserializing structs into the wrong interface errors gracefully
Types ¶
type Codec ¶
type Codec interface { MarshalInto(interface{}, *wrappers.Packer) error Unmarshal([]byte, interface{}) error // Returns the size, in bytes, of [value] when it's marshaled Size(value interface{}) (int, error) }
Codec marshals and unmarshals
type GeneralCodec ¶
GeneralCodec marshals and unmarshals structs including interfaces
type Manager ¶
type Manager interface { // Associate the given codec with the given version ID RegisterCodec(version uint16, codec Codec) error // Size returns the size, in bytes, of [value] when it's marshaled // using the codec with the given version. // RegisterCodec must have been called with that version. // If [value] is nil, returns [ErrMarshalNil] Size(version uint16, value interface{}) (int, error) // Marshal the given value using the codec with the given version. // RegisterCodec must have been called with that version. Marshal(version uint16, source interface{}) (destination []byte, err error) // Unmarshal the given bytes into the given destination. [destination] must // be a pointer or an interface. Returns the version of the codec that // produces the given bytes. Unmarshal(source []byte, destination interface{}) (version uint16, err error) }
Manager describes the functionality for managing codec versions.
func NewDefaultManager ¶
func NewDefaultManager() Manager
NewDefaultManager returns a new codec manager.
type MockManager ¶ added in v1.9.12
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶ added in v1.9.12
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) EXPECT ¶ added in v1.9.12
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) Marshal ¶ added in v1.9.12
func (m *MockManager) Marshal(arg0 uint16, arg1 interface{}) ([]byte, error)
Marshal mocks base method.
func (*MockManager) RegisterCodec ¶ added in v1.9.12
func (m *MockManager) RegisterCodec(arg0 uint16, arg1 Codec) error
RegisterCodec mocks base method.
type MockManagerMockRecorder ¶ added in v1.9.12
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) Marshal ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) Marshal(arg0, arg1 interface{}) *gomock.Call
Marshal indicates an expected call of Marshal.
func (*MockManagerMockRecorder) RegisterCodec ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) RegisterCodec(arg0, arg1 interface{}) *gomock.Call
RegisterCodec indicates an expected call of RegisterCodec.
func (*MockManagerMockRecorder) Size ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) Size(arg0, arg1 interface{}) *gomock.Call
Size indicates an expected call of Size.
func (*MockManagerMockRecorder) Unmarshal ¶ added in v1.9.12
func (mr *MockManagerMockRecorder) Unmarshal(arg0, arg1 interface{}) *gomock.Call
Unmarshal indicates an expected call of Unmarshal.
type MultipleVersionsStruct ¶
type MyInnerStruct ¶
type MyInnerStruct struct {
Str string `serialize:"true"`
}
func (*MyInnerStruct) Foo ¶
func (*MyInnerStruct) Foo() int
type MyInnerStruct2 ¶
type MyInnerStruct2 struct {
Bool bool `serialize:"true"`
}
func (*MyInnerStruct2) Foo ¶
func (*MyInnerStruct2) Foo() int
type MyInnerStruct3 ¶
type MyInnerStruct3 struct { Str string `serialize:"true"` M1 MyInnerStruct `serialize:"true"` F Foo `serialize:"true"` }
MyInnerStruct3 embeds Foo, an interface, so it has to implement TypeID and ConcreteInstance