mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 00:52:55 +00:00
Bulk move from k8s.io/kubectl
This commit is contained in:
53
vendor/github.com/modern-go/reflect2/tests/slice_struct_test.go
generated
vendored
Normal file
53
vendor/github.com/modern-go/reflect2/tests/slice_struct_test.go
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/modern-go/reflect2"
|
||||
)
|
||||
|
||||
func Test_slice_struct(t *testing.T) {
|
||||
var pInt = func(val int) *int {
|
||||
return &val
|
||||
}
|
||||
t.Run("SetIndex", testOp(func(api reflect2.API) interface{} {
|
||||
type TestObject struct {
|
||||
Field1 float64
|
||||
Field2 float64
|
||||
}
|
||||
obj := []TestObject{{}, {}}
|
||||
valType := api.TypeOf(obj).(reflect2.SliceType)
|
||||
valType.SetIndex(obj, 0, &TestObject{1, 3})
|
||||
valType.SetIndex(obj, 1, &TestObject{2, 4})
|
||||
return obj
|
||||
}))
|
||||
t.Run("SetIndex single ptr struct", testOp(func(api reflect2.API) interface{} {
|
||||
type TestObject struct {
|
||||
Field1 *int
|
||||
}
|
||||
obj := []TestObject{{}, {}}
|
||||
valType := api.TypeOf(obj).(reflect2.SliceType)
|
||||
valType.SetIndex(obj, 0, &TestObject{pInt(1)})
|
||||
valType.SetIndex(obj, 1, &TestObject{pInt(2)})
|
||||
return obj
|
||||
}))
|
||||
t.Run("SetIndex single chan struct", testOp(func(api reflect2.API) interface{} {
|
||||
type TestObject struct {
|
||||
Field1 chan int
|
||||
}
|
||||
obj := []TestObject{{}, {}}
|
||||
valType := api.TypeOf(obj).(reflect2.SliceType)
|
||||
valType.SetIndex(obj, 0, TestObject{})
|
||||
valType.SetIndex(obj, 1, TestObject{})
|
||||
return obj
|
||||
}))
|
||||
t.Run("SetIndex single func struct", testOp(func(api reflect2.API) interface{} {
|
||||
type TestObject struct {
|
||||
Field1 func()
|
||||
}
|
||||
obj := []TestObject{{}, {}}
|
||||
valType := api.TypeOf(obj).(reflect2.SliceType)
|
||||
valType.SetIndex(obj, 0, TestObject{})
|
||||
valType.SetIndex(obj, 1, TestObject{})
|
||||
return obj
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user