Skip to content

Commit

Permalink
add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brianolson committed Jul 31, 2024
1 parent 57553c5 commit 41fee79
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 0 deletions.
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
}

0 comments on commit 41fee79

Please sign in to comment.