Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,10 @@ func (g Gen) emitCborUnmarshalSliceField(w io.Writer, f Field) error {

case reflect.String:
subf := Field{
Type: e,
Pkg: f.Pkg,
Name: f.Name + "[" + f.IterLabel + "]",
Type: e,
Pkg: f.Pkg,
Pointer: pointer,
Name: f.Name + "[" + f.IterLabel + "]",
}
err := g.emitCborUnmarshalStringField(w, subf)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions testgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
types.TestCanonicalFieldOrder{},
types.MapStringString{},
types.TestSliceNilPreserve{},
types.StringPtrSlices{},
); err != nil {
panic(err)
}
Expand Down
223 changes: 223 additions & 0 deletions testing/cbor_map_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions testing/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,22 @@ func TestOptionalInts(t *testing.T) {
testValueRoundtrip(t, val, recepticle, WithGolden([]byte{0x84, 0xf6, 0x02, 0x03, 0xf6}))
}

func TestStringPtrSlices(t *testing.T) {
foo := "foo"
bar := "bar"
ob := StringPtrSlices{
Strings: []string{
"a", "b", "c",
},
StringPtrs: []*string{
&foo, nil, &bar,
},
}
ob2 := StringPtrSlices{}

testValueRoundtrip(t, &ob, &ob2)
}

func ptr[T any](v T) *T {
return &v
}
5 changes: 5 additions & 0 deletions testing/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,8 @@ func (ls LongString) Generate(rand *rand.Rand, size int) reflect.Value {
type BigIntContainer struct {
Int *big.Int
}

type StringPtrSlices struct {
Strings []string
StringPtrs []*string
}