Пример #1
0
func TestConstants(t *testing.T) {
	enumDefaultBaz := te.EnumDefaultBaz

	tests := []struct {
		name string
		i    interface{}
		o    interface{}
	}{
		{
			"primitiveContainers",
			tk.PrimitiveContainers,
			&tc.PrimitiveContainers{
				ListOfInts: []int64{1, 2, 3},
				SetOfStrings: map[string]struct{}{
					"foo": {},
					"bar": {},
				},
				SetOfBytes: map[int8]struct{}{
					1: {},
					2: {},
					3: {},
				},
				MapOfIntToString: map[int32]string{
					1: "1",
					2: "2",
					3: "3",
				},
				MapOfStringToBool: map[string]bool{
					"1": false,
					"2": true,
					"3": true,
				},
			},
		},
		{
			"enumContainers",
			tk.EnumContainers,
			&tc.EnumContainers{
				ListOfEnums: []te.EnumDefault{te.EnumDefaultBar, te.EnumDefaultFoo},
				SetOfEnums: map[te.EnumWithValues]struct{}{
					te.EnumWithValuesX: {},
					te.EnumWithValuesY: {},
				},
				MapOfEnums: map[te.EnumWithDuplicateValues]int32{
					te.EnumWithDuplicateValuesP: 1,
					te.EnumWithDuplicateValuesQ: 2,
				},
			},
		},
		{
			"containersOfContainers",
			tk.ContainersOfContainers,
			&tc.ContainersOfContainers{
				ListOfLists: [][]int32{
					{1, 2, 3},
					{4, 5, 6},
				},
				ListOfSets: []map[int32]struct{}{
					{
						1: struct{}{},
						2: struct{}{},
						3: struct{}{},
					},
					{
						4: struct{}{},
						5: struct{}{},
						6: struct{}{},
					},
				},
				ListOfMaps: []map[int32]int32{
					{
						1: 2,
						3: 4,
						5: 6,
					},
					{
						7:  8,
						9:  10,
						11: 12,
					},
				},
				SetOfSets: []map[string]struct{}{
					{
						"1": struct{}{},
						"2": struct{}{},
						"3": struct{}{},
					},
					{
						"4": struct{}{},
						"5": struct{}{},
						"6": struct{}{},
					},
				},
				SetOfLists: [][]string{
					{"1", "2", "3"},
					{"4", "5", "6"},
				},
				SetOfMaps: []map[string]string{
					{
						"1": "2",
						"3": "4",
						"5": "6",
					},
					{
						"7":  "8",
						"9":  "10",
						"11": "12",
					},
				},
				MapOfMapToInt: []struct {
					Key   map[string]int32
					Value int64
				}{
					{
						Key:   map[string]int32{"1": 1, "2": 2, "3": 3},
						Value: 100,
					},
					{
						Key:   map[string]int32{"4": 4, "5": 5, "6": 6},
						Value: 200,
					},
				},
				MapOfListToSet: []struct {
					Key   []int32
					Value map[int64]struct{}
				}{
					{
						Key: []int32{1, 2, 3},
						Value: map[int64]struct{}{
							1: {},
							2: {},
							3: {},
						},
					},
					{
						Key: []int32{4, 5, 6},
						Value: map[int64]struct{}{
							4: {},
							5: {},
							6: {},
						},
					},
				},
				MapOfSetToListOfDouble: []struct {
					Key   map[int32]struct{}
					Value []float64
				}{
					{
						Key: map[int32]struct{}{
							1: {},
							2: {},
							3: {},
						},
						Value: []float64{1.2, 3.4},
					},
					{
						Key: map[int32]struct{}{
							4: {},
							5: {},
							6: {},
						},
						Value: []float64{5.6, 7.8},
					},
				},
			},
		},
		{
			"structWithOptionalEnum",
			tk.StructWithOptionalEnum,
			&te.StructWithOptionalEnum{E: &enumDefaultBaz},
		},
		{
			"emptyException",
			tk.EmptyException,
			&tx.EmptyException{},
		},
		{
			"graph",
			tk.Graph,
			&ts.Graph{
				Edges: []*ts.Edge{
					{
						StartPoint: &ts.Point{X: 1, Y: 2},
						EndPoint:   &ts.Point{X: 3, Y: 4},
					},
					{
						StartPoint: &ts.Point{X: 5, Y: 6},
						EndPoint:   &ts.Point{X: 7, Y: 8},
					},
				},
			},
		},
		{
			"arbitraryValue",
			tk.ArbitraryValue,
			&tu.ArbitraryValue{
				ListValue: []*tu.ArbitraryValue{
					{BoolValue: boolp(true)},
					{Int64Value: int64p(2)},
					{StringValue: stringp("hello")},
					{
						MapValue: map[string]*tu.ArbitraryValue{
							"foo": {StringValue: stringp("bar")},
						},
					},
				},
			},
		},
		{
			"lastNode",
			tk.LastNode,
			&ts.Node{Value: 3},
		},
		{
			"node",
			tk.Node,
			&ts.Node{Value: 1, Tail: &ts.List{Value: 2, Tail: &ts.List{Value: 3}}},
		},
		{
			"i128",
			tk.I128,
			&td.I128{High: 1234, Low: 5678},
		},
		{
			"uuid",
			tk.UUID,
			&td.UUID{High: 1234, Low: 5678},
		},
		{
			"beginningOfTime",
			tk.BeginningOfTime,
			td.Timestamp(0),
		},
		{
			"frameGroup",
			tk.FrameGroup,
			td.FrameGroup{
				&ts.Frame{
					TopLeft: &ts.Point{X: 1, Y: 2},
					Size:    &ts.Size{Width: 100, Height: 200},
				},
				&ts.Frame{
					TopLeft: &ts.Point{X: 3, Y: 4},
					Size:    &ts.Size{Width: 300, Height: 400},
				},
			},
		},
		{
			"myEnum",
			tk.MyEnum,
			td.MyEnum(te.EnumWithValuesY),
		},
	}

	for _, tt := range tests {
		assert.Equal(t, tt.o, tt.i, tt.name)
	}
}
Пример #2
0
	Value []float64
}{{Key: map[int32]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}}, Value: []float64{1.2, 3.4}}, {Key: map[int32]struct{}{4: struct{}{}, 5: struct{}{}, 6: struct{}{}}, Value: []float64{5.6, 7.8}}}, SetOfLists: [][]string{[]string{"1", "2", "3"}, []string{"4", "5", "6"}}, SetOfMaps: []map[string]string{map[string]string{"1": "2", "3": "4", "5": "6"}, map[string]string{"7": "8", "9": "10", "11": "12"}}, SetOfSets: []map[string]struct{}{map[string]struct{}{"1": struct{}{}, "2": struct{}{}, "3": struct{}{}}, map[string]struct{}{"4": struct{}{}, "5": struct{}{}, "6": struct{}{}}}}

var EmptyException *exceptions.EmptyException = &exceptions.EmptyException{}

var EnumContainers *containers.EnumContainers = &containers.EnumContainers{ListOfEnums: []enums.EnumDefault{enums.EnumDefaultBar, enums.EnumDefaultFoo}, MapOfEnums: map[enums.EnumWithDuplicateValues]int32{enums.EnumWithDuplicateValuesP: 1, enums.EnumWithDuplicateValuesQ: 2}, SetOfEnums: map[enums.EnumWithValues]struct{}{enums.EnumWithValuesX: struct{}{}, enums.EnumWithValuesY: struct{}{}}}

var FrameGroup typedefs.FrameGroup = typedefs.FrameGroup{&structs.Frame{Size: &structs.Size{Height: 200, Width: 100}, TopLeft: &structs.Point{X: 1, Y: 2}}, &structs.Frame{Size: &structs.Size{Height: 400, Width: 300}, TopLeft: &structs.Point{X: 3, Y: 4}}}

var Graph *structs.Graph = &structs.Graph{Edges: []*structs.Edge{&structs.Edge{EndPoint: &structs.Point{X: 3, Y: 4}, StartPoint: &structs.Point{X: 1, Y: 2}}, &structs.Edge{EndPoint: &structs.Point{X: 7, Y: 8}, StartPoint: &structs.Point{X: 5, Y: 6}}}}

var I128 *typedefs.I128 = &typedefs.I128{High: 1234, Low: 5678}

var LastNode *structs.Node = &structs.Node{Value: 3}

const Lower enums.LowerCaseEnum = enums.LowerCaseEnumItems

const MyEnum typedefs.MyEnum = typedefs.MyEnum(enums.EnumWithValuesY)

var Node *structs.Node = &structs.Node{Tail: &structs.List{Tail: &structs.List{Value: 3}, Value: 2}, Value: 1}

var PrimitiveContainers *containers.PrimitiveContainers = &containers.PrimitiveContainers{ListOfInts: []int64{1, 2, 3}, MapOfIntToString: map[int32]string{1: "1", 2: "2", 3: "3"}, MapOfStringToBool: map[string]bool{"1": false, "2": true, "3": true}, SetOfBytes: map[int8]struct{}{1: struct{}{}, 2: struct{}{}, 3: struct{}{}}, SetOfStrings: map[string]struct{}{"foo": struct{}{}, "bar": struct{}{}}}

func _EnumDefault_ptr(v enums.EnumDefault) *enums.EnumDefault {
	return &v
}

var StructWithOptionalEnum *enums.StructWithOptionalEnum = &enums.StructWithOptionalEnum{E: _EnumDefault_ptr(enums.EnumDefaultBaz)}

var UUID *typedefs.UUID = &typedefs.UUID{High: 1234, Low: 5678}