github.com/glycerine/zebrapack@v4.1.1-0.20181107023619-e955d028f9bf+incompatible/cmd/addzid/old_bambam_tests/go2cpType_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "testing" 6 7 cv "github.com/glycerine/goconvey/convey" 8 ) 9 10 func Test001GoToCapTypeConversion(t *testing.T) { 11 12 cv.Convey("Given a go structs: type s1 struct { Ptrs []*int }", t, func() { 13 cv.Convey(`then the goTypeSeq should be {"[]", "*", "int"} and the capTypeSeq should be {"List", "*", "Int64"} `, func() { 14 15 src := ` 16 type s1 struct { 17 Ptrs []*int 18 } 19 ` 20 21 x := NewExtractor() 22 defer x.Cleanup() 23 _, err := ExtractStructs("", "package main; "+src, x) 24 if err != nil { 25 panic(err) 26 } 27 28 x.GenerateTranslators() 29 30 capTypeSeq := []string{} 31 goTypeSeq := []string{"[]", "*", "int"} 32 var capTypeDisplay string 33 capTypeSeq, capTypeDisplay = x.GoTypeToCapnpType(nil, goTypeSeq) 34 35 fmt.Printf("capTypeSeq = '%v', goTypeSeq = '%v', capTypeDispaly = '%v'\n", capTypeSeq, goTypeSeq, capTypeDisplay) 36 37 cv.So(len(capTypeSeq), cv.ShouldEqual, 3) 38 cv.So(capTypeSeq[0], cv.ShouldEqual, "List") 39 cv.So(capTypeSeq[1], cv.ShouldEqual, "*") 40 cv.So(capTypeSeq[2], cv.ShouldEqual, "Int64") 41 42 cv.So(capTypeDisplay, cv.ShouldEqual, "List(Int64)") 43 }) 44 }) 45 }