slice_string_test.go 348 B

12345678910111213141516
  1. package test
  2. import (
  3. "testing"
  4. "github.com/modern-go/reflect2"
  5. )
  6. func Test_slice_string(t *testing.T) {
  7. t.Run("SetIndex", testOp(func(api reflect2.API) interface{} {
  8. obj := []string{"hello", "world"}
  9. valType := api.TypeOf(obj).(reflect2.SliceType)
  10. valType.SetIndex(&obj, 0, "hi")
  11. valType.SetIndex(&obj, 1, "there")
  12. return obj
  13. }))
  14. }