slice_bytes_test.go 380 B

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