sftest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SamplesArr = []Recording{

	Arr(0, structform.AnyType),
	Arr(-1, structform.AnyType),

	Arr(1, structform.AnyType,
		Arr(0, structform.AnyType),
	),
	Arr(-1, structform.AnyType,
		Arr(0, structform.AnyType),
	),
	Arr(-1, structform.AnyType,
		Arr(-1, structform.AnyType),
	),

	Arr(-1, structform.AnyType,
		NilRec{},
		BoolRec{true},
		BoolRec{false},
		IntRec{1},
		Int64Rec{12345678910},
		Float32Rec{3.14},
		Float64Rec{7e+09},
		StringRec{"test"},
	),
	Arr(2, structform.AnyType,
		Int8Rec{1},
		BoolRec{true},
	),
	{
		Int8ArrRec{[]int8{1, 2, 3}},
	},
	{
		StringArrRec{[]string{"a", "b", "c"}},
	},
}
View Source
var SamplesCombinations = []Recording{

	Arr(-1, structform.AnyType,
		Obj(-1, structform.AnyType)),
	Arr(1, structform.AnyType,
		Obj(0, structform.AnyType)),
	Arr(-1, structform.AnyType,
		Obj(-1, structform.AnyType,
			"a", IntRec{-1},
		),
		Obj(1, structform.UintType,
			"a", UintRec{1},
		),
	),
	Arr(2, structform.AnyType,
		Obj(-1, structform.AnyType,
			"a", IntRec{-1},
		),
		Obj(1, structform.UintType,
			"a", UintRec{1},
		),
	),

	Obj(-1, structform.AnyType,
		"a", Arr(3, structform.IntType,
			IntRec{1}, IntRec{2}, IntRec{3}),
	),
	Obj(1, structform.AnyType,
		"a", Arr(3, structform.IntType,
			IntRec{1}, IntRec{2}, IntRec{3}),
	),
	Obj(1, structform.AnyType,
		"a", Int8ArrRec{[]int8{1, 2, 3}},
	),
}
View Source
var SamplesObj = []Recording{

	Obj(-1, structform.AnyType),
	Obj(0, structform.AnyType),

	Obj(-1, structform.AnyType,
		"a", NilRec{},
	),

	Obj(-1, structform.AnyType,
		"a", StringRec{"test"}),
	Obj(1, structform.StringType,
		"a", StringRec{"test"}),
	Obj(-1, structform.AnyType,
		"a", BoolRec{true},
		"b", BoolRec{false},
	),
	Obj(2, structform.AnyType,
		"a", BoolRec{true},
		"b", BoolRec{false},
	),
	Obj(-1, structform.BoolType,
		"a", BoolRec{true},
		"b", BoolRec{false},
	),
	Obj(2, structform.BoolType,
		"a", BoolRec{true},
		"b", BoolRec{false},
	),
	Obj(-1, structform.AnyType,
		"a", UintRec{1},
		"b", Float64Rec{3.14},
		"c", StringRec{"test"},
		"d", BoolRec{true},
	),

	{
		StringObjRec{map[string]string{
			"a": "test1",
			"b": "test2",
			"c": "test3",
		}},
	},
	{
		UintObjRec{map[string]uint{
			"a": 1,
			"b": 2,
			"c": 3,
		}},
	},
}
View Source
var SamplesPrimitives = []Recording{

	{NilRec{}},
	{BoolRec{true}},
	{BoolRec{false}},
	{StringRec{"test"}},
	{StringRec{`test with " being special`}},
	{StringRec{""}},

	{IntRec{8}},
	{IntRec{42}},
	{IntRec{100}},
	{IntRec{-90}},
	{IntRec{12345678}},
	{IntRec{-12345678}},
	{Int8Rec{8}},
	{Int8Rec{42}},
	{Int8Rec{100}},
	{Int8Rec{-90}},
	{Int16Rec{8}},
	{Int16Rec{42}},
	{Int16Rec{100}},
	{Int16Rec{-90}},
	{Int16Rec{500}},
	{Int16Rec{-500}},
	{Int32Rec{8}},
	{Int32Rec{42}},
	{Int32Rec{100}},
	{Int32Rec{-90}},
	{Int32Rec{500}},
	{Int32Rec{-500}},
	{Int32Rec{12345678}},
	{Int32Rec{-12345678}},
	{Int64Rec{8}},
	{Int64Rec{42}},
	{Int64Rec{100}},
	{Int64Rec{-90}},
	{Int64Rec{500}},
	{Int64Rec{-500}},
	{Int64Rec{123456781234}},
	{Int64Rec{-123456781234}},

	{UintRec{8}},
	{UintRec{42}},
	{UintRec{100}},
	{UintRec{12345678}},
	{Uint8Rec{8}},
	{Uint8Rec{42}},
	{Uint8Rec{100}},
	{ByteRec{8}},
	{ByteRec{42}},
	{ByteRec{100}},
	{Uint16Rec{8}},
	{Uint16Rec{42}},
	{Uint16Rec{100}},
	{Uint16Rec{500}},
	{Uint32Rec{8}},
	{Uint32Rec{42}},
	{Uint32Rec{100}},
	{Uint32Rec{500}},
	{Uint32Rec{12345678}},
	{Uint64Rec{8}},
	{Uint64Rec{42}},
	{Uint64Rec{100}},
	{Uint64Rec{500}},
	{Uint64Rec{123456781234}},

	{Float32Rec{3.14}},
	{Float32Rec{-3.14}},
	{Float64Rec{3.14}},
	{Float64Rec{-3.14}},
}

Functions

func TestEncodeParseConsistent

func TestEncodeParseConsistent(
	t *testing.T,
	samples []Recording,
	constr func() (structform.Visitor, func(structform.Visitor) error),
)

Types

type ArrayFinishRec

type ArrayFinishRec struct{}

func (ArrayFinishRec) Replay

type ArrayStartRec

type ArrayStartRec struct {
	Len int
	T   structform.BaseType
}

func (ArrayStartRec) Replay

type BoolRec

type BoolRec struct{ Value bool }

func (BoolRec) Replay

func (r BoolRec) Replay(vs structform.ExtVisitor) error

type ByteRec

type ByteRec struct{ Value byte }

func (ByteRec) Replay

func (r ByteRec) Replay(vs structform.ExtVisitor) error

type Float32Rec

type Float32Rec struct{ Value float32 }

func (Float32Rec) Replay

func (r Float32Rec) Replay(vs structform.ExtVisitor) error

type Float64Rec

type Float64Rec struct{ Value float64 }

func (Float64Rec) Replay

func (r Float64Rec) Replay(vs structform.ExtVisitor) error

type Int16Rec

type Int16Rec struct{ Value int16 }

func (Int16Rec) Replay

func (r Int16Rec) Replay(vs structform.ExtVisitor) error

type Int32Rec

type Int32Rec struct{ Value int32 }

func (Int32Rec) Replay

func (r Int32Rec) Replay(vs structform.ExtVisitor) error

type Int64Rec

type Int64Rec struct{ Value int64 }

func (Int64Rec) Replay

func (r Int64Rec) Replay(vs structform.ExtVisitor) error

type Int8ArrRec

type Int8ArrRec struct{ Value []int8 }

extended (yet) non-recordible records

func (Int8ArrRec) Replay

func (r Int8ArrRec) Replay(vs structform.ExtVisitor) error

type Int8Rec

type Int8Rec struct{ Value int8 }

func (Int8Rec) Replay

func (r Int8Rec) Replay(vs structform.ExtVisitor) error

type IntRec

type IntRec struct{ Value int }

func (IntRec) Replay

func (r IntRec) Replay(vs structform.ExtVisitor) error

type NilRec

type NilRec struct{}

func (NilRec) Replay

func (NilRec) Replay(vs structform.ExtVisitor) error

type ObjectFinishRec

type ObjectFinishRec struct{}

func (ObjectFinishRec) Replay

type ObjectKeyRec

type ObjectKeyRec struct{ Value string }

func (ObjectKeyRec) Replay

func (r ObjectKeyRec) Replay(vs structform.ExtVisitor) error

type ObjectStartRec

type ObjectStartRec struct {
	Len int
	T   structform.BaseType
}

func (ObjectStartRec) Replay

type Record

type Record interface {
	Replay(v structform.ExtVisitor) error
}

func Arr

func Arr(l int, t structform.BaseType, elems ...interface{}) []Record

func Obj

func Obj(l int, t structform.BaseType, kv ...interface{}) []Record

type Recording

type Recording []Record

func (Recording) Assert

func (r Recording) Assert(t *testing.T, expected Recording)

func (*Recording) OnArrayFinished

func (r *Recording) OnArrayFinished() error

func (*Recording) OnArrayStart

func (r *Recording) OnArrayStart(len int, baseType structform.BaseType) error

func (*Recording) OnBool

func (r *Recording) OnBool(b bool) error

func (*Recording) OnByte

func (r *Recording) OnByte(i byte) error

func (*Recording) OnFloat32

func (r *Recording) OnFloat32(i float32) error

func (*Recording) OnFloat64

func (r *Recording) OnFloat64(i float64) error

func (*Recording) OnInt

func (r *Recording) OnInt(i int) error

func (*Recording) OnInt16

func (r *Recording) OnInt16(i int16) error

func (*Recording) OnInt32

func (r *Recording) OnInt32(i int32) error

func (*Recording) OnInt64

func (r *Recording) OnInt64(i int64) error

func (*Recording) OnInt8

func (r *Recording) OnInt8(i int8) error

func (*Recording) OnKey

func (r *Recording) OnKey(s string) error

func (*Recording) OnNil

func (r *Recording) OnNil() error

func (*Recording) OnObjectFinished

func (r *Recording) OnObjectFinished() error

func (*Recording) OnObjectStart

func (r *Recording) OnObjectStart(len int, baseType structform.BaseType) error

func (*Recording) OnString

func (r *Recording) OnString(s string) error

func (*Recording) OnUint

func (r *Recording) OnUint(i uint) error

func (*Recording) OnUint16

func (r *Recording) OnUint16(i uint16) error

func (*Recording) OnUint32

func (r *Recording) OnUint32(i uint32) error

func (*Recording) OnUint64

func (r *Recording) OnUint64(i uint64) error

func (*Recording) OnUint8

func (r *Recording) OnUint8(i uint8) error

func (*Recording) Replay

func (rec *Recording) Replay(vs structform.Visitor) error

func (Recording) ToJSON

func (r Recording) ToJSON() (string, error)

type StringArrRec

type StringArrRec struct{ Value []string }

func (StringArrRec) Replay

func (r StringArrRec) Replay(vs structform.ExtVisitor) error

type StringObjRec

type StringObjRec struct{ Value map[string]string }

func (StringObjRec) Replay

func (r StringObjRec) Replay(vs structform.ExtVisitor) error

type StringRec

type StringRec struct{ Value string }

func (StringRec) Replay

func (r StringRec) Replay(vs structform.ExtVisitor) error

type Uint16Rec

type Uint16Rec struct{ Value uint16 }

func (Uint16Rec) Replay

func (r Uint16Rec) Replay(vs structform.ExtVisitor) error

type Uint32Rec

type Uint32Rec struct{ Value uint32 }

func (Uint32Rec) Replay

func (r Uint32Rec) Replay(vs structform.ExtVisitor) error

type Uint64Rec

type Uint64Rec struct{ Value uint64 }

func (Uint64Rec) Replay

func (r Uint64Rec) Replay(vs structform.ExtVisitor) error

type Uint8Rec

type Uint8Rec struct{ Value uint8 }

func (Uint8Rec) Replay

func (r Uint8Rec) Replay(vs structform.ExtVisitor) error

type UintObjRec

type UintObjRec struct{ Value map[string]uint }

func (UintObjRec) Replay

func (r UintObjRec) Replay(vs structform.ExtVisitor) error

type UintRec

type UintRec struct{ Value uint }

func (UintRec) Replay

func (r UintRec) Replay(vs structform.ExtVisitor) error

Jump to

Keyboard shortcuts

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