-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathlistlist_test.go
44 lines (35 loc) · 904 Bytes
/
listlist_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"testing"
cv "github.com/glycerine/goconvey/convey"
)
func Test010ListListStruct(t *testing.T) {
cv.Convey("Given a go [][]struct that maps to List(List(Struct)) in capnproto", t, func() {
cv.Convey("then out list of list of struct serialization code should work", func() {
ex0 := `
type Nester1 struct {
Strs []string
}
type RWTest struct {
NestMatrix [][]Nester1
}
`
cv.So(ExtractString2String(ex0), ShouldContainModuloWhiteSpace, `
func RWTestGoToCapn(seg *capn.Segment, src *RWTest) RWTestCapn {
dest := AutoNewRWTestCapn(seg)
// NestMatrix -> Nester1Capn (go slice to capn list)
if len(src.NestMatrix) > 0 {
plist := seg.NewPointerList(len(src.NestMatrix))
i := 0
for _, ele := range src.NestMatrix {
plist.Set(i, capn.Object(SliceNester1ToNester1CapnList(seg, ele)))
i++
}
dest.SetNestMatrix(plist)
}
return dest
}
`)
})
})
}