mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 17:08:38 +00:00
genbindings/test: add simple TestParseTypeString() test case
This commit is contained in:
parent
b3d55cc17f
commit
3ef53b4224
@ -404,7 +404,7 @@ func parseTypeString(typeString string) (CppParameter, []CppParameter, error) {
|
||||
epos := strings.LastIndex(typeString, `)`)
|
||||
|
||||
if opos == -1 || epos == -1 {
|
||||
return CppParameter{}, nil, fmt.Errorf("Type string %q missing brackets")
|
||||
return CppParameter{}, nil, fmt.Errorf("Type string %q missing brackets", typeString)
|
||||
}
|
||||
|
||||
returnType := parseSingleTypeString(strings.TrimSpace(typeString[0:opos]))
|
||||
|
39
cmd/genbindings/clang2il_test.go
Normal file
39
cmd/genbindings/clang2il_test.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseTypeString(t *testing.T) {
|
||||
type testCase struct {
|
||||
input string
|
||||
expectReturn CppParameter
|
||||
expectParams []CppParameter
|
||||
}
|
||||
|
||||
cases := []testCase{
|
||||
testCase{
|
||||
input: "void (bool)",
|
||||
expectReturn: CppParameter{ParameterType: "void"},
|
||||
expectParams: []CppParameter{
|
||||
CppParameter{ParameterType: "bool"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
r, p, err := parseTypeString(tc.input)
|
||||
if err != nil {
|
||||
t.Errorf("Test %q got error %v", tc.input, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(r, tc.expectReturn) {
|
||||
t.Errorf("Test %q got return=%#v, expected=%#v", tc.input, r, tc.expectReturn)
|
||||
}
|
||||
if !reflect.DeepEqual(p, tc.expectParams) {
|
||||
t.Errorf("Test %q got return=%#v, expected=%#v", tc.input, r, tc.expectReturn)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user