Skip to content
Open
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
26 changes: 26 additions & 0 deletions marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,32 @@ func TestStruct(test *testing.T) {
decodeCompareLE(exp, &out, &in)
}()

// slice of struct in a struct
func() {
type st2 struct {
I2 int16
B2 byte `binary:"int8"`
}
type st1 struct {
I1 int16
B1 byte `binary:"int8"`
ST2 []st2 `binary:"[I1]struct"`
}

in := st1{
2,
1,
[]st2{
{2, 4},
{3, 5},
},
}
exp := []byte{0x02, 0x00, 0x01, 0x02, 0x00, 0x04, 0x03, 0x00, 0x05}
encodeCompareLE(in, exp)
out := st1{}
decodeCompareLE(exp, &out, &in)
}()

// some complex structure
func() {
type t struct {
Expand Down