aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/binapi-generator/generator_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/binapi-generator/generator_test.go')
-rw-r--r--cmd/binapi-generator/generator_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/cmd/binapi-generator/generator_test.go b/cmd/binapi-generator/generator_test.go
index a42e794..1fcbb66 100644
--- a/cmd/binapi-generator/generator_test.go
+++ b/cmd/binapi-generator/generator_test.go
@@ -120,7 +120,7 @@ func TestReadJson(t *testing.T) {
result, err := parseJSON(inputData)
Expect(err).ShouldNot(HaveOccurred())
Expect(result).ToNot(BeNil())
- Expect(result.Len()).To(BeEquivalentTo(3))
+ Expect(result.Len()).To(BeEquivalentTo(5))
}
func TestReadJsonError(t *testing.T) {
@@ -255,8 +255,9 @@ func TestGenerateMessageFieldTypes(t *testing.T) {
func TestGenerateMessageFieldMessages(t *testing.T) {
// expected results according to acl.api.json in testdata
- expectedTypes := []string{"\tMajor uint32", "\tMinor uint32", "\tACLIndex uint32",
- "\tTag []byte `struc:\"[64]byte\"`", "\tACLIndex uint32", "\tRetval int32", "\tACLIndex uint32"}
+ expectedFields := []string{"\tMajor uint32", "\tMinor uint32", "\tRetval int32",
+ "\tVpePid uint32", "\tACLIndex uint32", "\tTag []byte `struc:\"[64]byte\"`",
+ "\tCount uint32"}
RegisterTestingT(t)
// prepare context
testCtx := new(context)
@@ -269,7 +270,7 @@ func TestGenerateMessageFieldMessages(t *testing.T) {
Expect(err).ShouldNot(HaveOccurred())
Expect(inFile).ToNot(BeNil())
- // test types
+ // test message fields
messages := inFile.Map("messages")
customIndex := 0
fields := make([]string, 0)
@@ -284,8 +285,12 @@ func TestGenerateMessageFieldMessages(t *testing.T) {
}
err := processMessageField(testCtx, &fields, field, false)
Expect(err).ShouldNot(HaveOccurred())
- Expect(fields[customIndex]).To(BeEquivalentTo(expectedTypes[customIndex]))
+ Expect(fields[customIndex]).To(BeEquivalentTo(expectedFields[customIndex]))
customIndex++
+ if customIndex >= len(expectedFields) {
+ /* there is too much fields now for one UT... */
+ return
+ }
}
}
}