Documentation ¶
Overview ¶
Package codectest provides a test suite for testing codec implementations.
Index ¶
- Variables
- func FuzzStructUnmarshal(codec codecpkg.GeneralCodec, f *testing.F)
- func RunAll(t *testing.T, ctor func() codecpkg.GeneralCodec)
- func RunAllMultipleTags(t *testing.T, ctor func() codecpkg.GeneralCodec)
- func TestArray(t testing.TB, codec codecpkg.GeneralCodec)
- func TestArrayOfInterface(t testing.TB, codec codecpkg.GeneralCodec)
- func TestBigArray(t testing.TB, codec codecpkg.GeneralCodec)
- func TestBool(t testing.TB, codec codecpkg.GeneralCodec)
- func TestCanMarshalLargeSlices(t testing.TB, codec codecpkg.GeneralCodec)
- func TestEmptySliceSerialization(t testing.TB, codec codecpkg.GeneralCodec)
- func TestExtraSpace(t testing.TB, codec codecpkg.GeneralCodec)
- func TestInterface(t testing.TB, codec codecpkg.GeneralCodec)
- func TestMap(t testing.TB, codec codecpkg.GeneralCodec)
- func TestMapWithEmptySerialization(t testing.TB, codec codecpkg.GeneralCodec)
- func TestMapWithEmptySerializationError(t testing.TB, codec codecpkg.GeneralCodec)
- func TestMaxSizeSlice(t testing.TB, codec codecpkg.GeneralCodec)
- func TestMultipleTags(t testing.TB, codec codecpkg.GeneralCodec)
- func TestNegativeNumbers(t testing.TB, codec codecpkg.GeneralCodec)
- func TestNilSlice(t testing.TB, codec codecpkg.GeneralCodec)
- func TestNilSliceSerialization(t testing.TB, codec codecpkg.GeneralCodec)
- func TestPointerToInterface(t testing.TB, codec codecpkg.GeneralCodec)
- func TestPointerToStruct(t testing.TB, codec codecpkg.GeneralCodec)
- func TestRegisterStructTwice(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSerializeOfNoSerializeField(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSerializeUnexportedField(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSlice(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceLengthOverflow(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceOfInterface(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceOfStruct(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceTooLarge(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceWithEmptySerialization(t testing.TB, codec codecpkg.GeneralCodec)
- func TestSliceWithEmptySerializationError(t testing.TB, codec codecpkg.GeneralCodec)
- func TestString(t testing.TB, codec codecpkg.GeneralCodec)
- func TestStruct(t testing.TB, codec codecpkg.GeneralCodec)
- func TestTooLargeUnmarshal(t testing.TB, codec codecpkg.GeneralCodec)
- func TestUInt32(t testing.TB, codec codecpkg.GeneralCodec)
- func TestUIntPtr(t testing.TB, codec codecpkg.GeneralCodec)
- func TestUnmarshalInvalidInterface(t testing.TB, codec codecpkg.GeneralCodec)
- type Foo
- type MultipleVersionsStruct
- type MyInnerStruct
- type MyInnerStruct2
- type MyInnerStruct3
- type NamedTest
Constants ¶
This section is empty.
Variables ¶
var ( Tests = []NamedTest{ {"Struct", TestStruct}, {"Register Struct Twice", TestRegisterStructTwice}, {"UInt32", TestUInt32}, {"UIntPtr", TestUIntPtr}, {"Slice", TestSlice}, {"Max-Size Slice", TestMaxSizeSlice}, {"Bool", TestBool}, {"Array", TestArray}, {"Big Array", TestBigArray}, {"Pointer To Struct", TestPointerToStruct}, {"Slice Of Struct", TestSliceOfStruct}, {"Interface", TestInterface}, {"Slice Of Interface", TestSliceOfInterface}, {"Array Of Interface", TestArrayOfInterface}, {"Pointer To Interface", TestPointerToInterface}, {"String", TestString}, {"Nil Slice", TestNilSlice}, {"Serialize Unexported Field", TestSerializeUnexportedField}, {"Serialize Of NoSerialize Field", TestSerializeOfNoSerializeField}, {"Nil Slice Serialization", TestNilSliceSerialization}, {"Empty Slice Serialization", TestEmptySliceSerialization}, {"Slice With Empty Serialization", TestSliceWithEmptySerialization}, {"Slice With Empty Serialization Error", TestSliceWithEmptySerializationError}, {"Map With Empty Serialization", TestMapWithEmptySerialization}, {"Map With Empty Serialization Error", TestMapWithEmptySerializationError}, {"Slice Too Large", TestSliceTooLarge}, {"Negative Numbers", TestNegativeNumbers}, {"Too Large Unmarshal", TestTooLargeUnmarshal}, {"Unmarshal Invalid Interface", TestUnmarshalInvalidInterface}, {"Extra Space", TestExtraSpace}, {"Slice Length Overflow", TestSliceLengthOverflow}, {"Map", TestMap}, {"Can Marshal Large Slices", TestCanMarshalLargeSlices}, } MultipleTagsTests = []NamedTest{ {"Multiple Tags", TestMultipleTags}, } )
Functions ¶
func FuzzStructUnmarshal ¶
func FuzzStructUnmarshal(codec codecpkg.GeneralCodec, f *testing.F)
func RunAll ¶
func RunAll(t *testing.T, ctor func() codecpkg.GeneralCodec)
RunAll runs all Tests, constructing a new GeneralCodec for each.
func RunAllMultipleTags ¶
func RunAllMultipleTags(t *testing.T, ctor func() codecpkg.GeneralCodec)
RunAll runs all MultipleTagsTests, constructing a new GeneralCodec for each.
func TestArray ¶
func TestArray(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling an array
func TestArrayOfInterface ¶
func TestArrayOfInterface(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling an array of interfaces
func TestBigArray ¶
func TestBigArray(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a really big array
func TestCanMarshalLargeSlices ¶
func TestCanMarshalLargeSlices(t testing.TB, codec codecpkg.GeneralCodec)
func TestEmptySliceSerialization ¶
func TestEmptySliceSerialization(t testing.TB, codec codecpkg.GeneralCodec)
Test marshaling a slice that has 0 elements (but isn't nil)
func TestExtraSpace ¶
func TestExtraSpace(t testing.TB, codec codecpkg.GeneralCodec)
Test unmarshaling something with extra data
func TestInterface ¶
func TestInterface(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling an interface
func TestMapWithEmptySerialization ¶
func TestMapWithEmptySerialization(t testing.TB, codec codecpkg.GeneralCodec)
Test marshaling empty map of zero length structs
func TestMapWithEmptySerializationError ¶
func TestMapWithEmptySerializationError(t testing.TB, codec codecpkg.GeneralCodec)
func TestMaxSizeSlice ¶
func TestMaxSizeSlice(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling/unmarshalling largest possible slice
func TestMultipleTags ¶
func TestMultipleTags(t testing.TB, codec codecpkg.GeneralCodec)
func TestNegativeNumbers ¶
func TestNegativeNumbers(t testing.TB, codec codecpkg.GeneralCodec)
Ensure serializing structs with negative number members works
func TestNilSlice ¶
func TestNilSlice(t testing.TB, codec codecpkg.GeneralCodec)
Ensure a nil slice is unmarshaled to slice with length 0
func TestNilSliceSerialization ¶
func TestNilSliceSerialization(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling of nil slice
func TestPointerToInterface ¶
func TestPointerToInterface(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a pointer to an interface
func TestPointerToStruct ¶
func TestPointerToStruct(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a pointer to a struct
func TestRegisterStructTwice ¶
func TestRegisterStructTwice(t testing.TB, codec codecpkg.GeneralCodec)
func TestSerializeOfNoSerializeField ¶
func TestSerializeOfNoSerializeField(t testing.TB, codec codecpkg.GeneralCodec)
func TestSerializeUnexportedField ¶
func TestSerializeUnexportedField(t testing.TB, codec codecpkg.GeneralCodec)
Ensure that trying to serialize a struct with an unexported member that has `serialize:"true"` returns error
func TestSliceLengthOverflow ¶
func TestSliceLengthOverflow(t testing.TB, codec codecpkg.GeneralCodec)
Ensure deserializing slices whose lengths exceed MaxInt32 error correctly
func TestSliceOfInterface ¶
func TestSliceOfInterface(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a slice of interfaces
func TestSliceOfStruct ¶
func TestSliceOfStruct(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a slice of structs
func TestSliceTooLarge ¶
func TestSliceTooLarge(t testing.TB, codec codecpkg.GeneralCodec)
func TestSliceWithEmptySerialization ¶
func TestSliceWithEmptySerialization(t testing.TB, codec codecpkg.GeneralCodec)
Test marshaling empty slice of zero length structs
func TestSliceWithEmptySerializationError ¶
func TestSliceWithEmptySerializationError(t testing.TB, codec codecpkg.GeneralCodec)
func TestString ¶
func TestString(t testing.TB, codec codecpkg.GeneralCodec)
Test marshalling a string
func TestStruct ¶
func TestStruct(t testing.TB, codec codecpkg.GeneralCodec)
Test marshaling/unmarshaling a complicated struct
func TestTooLargeUnmarshal ¶
func TestTooLargeUnmarshal(t testing.TB, codec codecpkg.GeneralCodec)
Ensure deserializing structs with too many bytes errors correctly
func TestUInt32 ¶
func TestUInt32(t testing.TB, codec codecpkg.GeneralCodec)
func TestUIntPtr ¶
func TestUIntPtr(t testing.TB, codec codecpkg.GeneralCodec)
func TestUnmarshalInvalidInterface ¶
func TestUnmarshalInvalidInterface(t testing.TB, codec codecpkg.GeneralCodec)
Ensure deserializing structs into the wrong interface errors gracefully
Types ¶
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