mirror of
https://github.com/mappu/miqt.git
synced 2024-12-23 01:18:37 +00:00
40 lines
830 B
Go
40 lines
830 B
Go
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|