-
Notifications
You must be signed in to change notification settings - Fork 12
/
types_test.go
65 lines (51 loc) · 1.59 KB
/
types_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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"testing"
cv "github.com/glycerine/goconvey/convey"
)
func TestBasicTypesInStruct(t *testing.T) {
cv.Convey("Given a parsable golang source file with a simple struct", t, func() {
cv.Convey("then we can extract the struct and convert the basic types to capnp", func() {
in1 := `
type In1 struct {
Str string
N int
D float64
}`
expect1 := `struct In1Capn { str @0: Text; n @1: Int64; d @2: Float64; } `
// List(Float64) next
cv.So(ExtractString2String(in1), ShouldStartWithModuloWhiteSpace, expect1)
})
})
}
func TestCaseConversion(t *testing.T) {
cv.Convey("Given a parsable golang source file with a simple struct", t, func() {
cv.Convey("then the capnp generated struct has uppercase struct name and lowercase field name, as per capnp requirements.", func() {
in1 := `
type in1 struct {
Str string
N int
D float64
}`
expect1 := `struct In1Capn { str @0: Text; n @1: Int64; d @2: Float64;}`
// List(Float64) next
cv.So(ExtractString2String(in1), ShouldStartWithModuloWhiteSpace, expect1)
})
})
}
/* unclear if we really want this or not
func TestNonStructTypeDefsAreIgnored(t *testing.T) {
cv.Convey("Given a go type definition 'type SyncMsg int32' that isn't a struct definition,", t, func() {
cv.Convey("then bambam should not define a new SyncMsgCapn for it, but should generate a capnp Int32 field in the capnp struct", func() {
in1 := `
type S struct {
A SyncMsg
}
type SyncMsg int32
`
expect1 := `struct SCapn { a @0: Int32; } `
cv.So(ExtractString2String(in1), ShouldStartWithModuloWhiteSpace, expect1)
})
})
}
*/