work in proggress

This commit is contained in:
Radu Ioan Fericean
2016-04-18 19:07:37 +03:00
parent 75a565a658
commit d158fcec80
3 changed files with 22 additions and 9 deletions

View File

@@ -8,14 +8,21 @@ func (rpc *RpcStruct) Hopa(normal string, out *float64) error {
return nil
}
func TestRPCObjectSimple(t *testing.T) {
func (rpc *RpcStruct) Tropa(pointer *string, out *float64) error {
return nil
}
func TestRPCObjectPointer(t *testing.T) {
RegisterRpcObject("", &RpcStruct{})
if len(RpcObjects) != 1 {
if len(RpcObjects) != 2 {
t.Errorf("error registering rpc object: %v", RpcObjects)
}
x, found := RpcObjects["RpcStruct.Hopa"]
if found {
if !found {
t.Errorf("error getting rpcobject: %v (%+v)", RpcObjects, x)
}
x, found = RpcObjects["RpcStruct.Tropa"]
if !found {
t.Errorf("error getting rpcobject: %v (%+v)", RpcObjects, x)
}
}

View File

@@ -29,8 +29,8 @@ func RegisterRpcObject(name string, rpcObject interface{}) {
if methodType.NumIn() == 3 { // if it has three parameters (one is self and two are rpc params)
RpcObjects[name+"."+method.Name] = &RpcObject{
Object: objType,
InParam: reflect.New(methodType.In(1)).Elem().Interface(),
OutParam: reflect.New(methodType.In(2)).Elem().Interface(),
InParam: reflect.New(methodType.In(1)).Interface(),
OutParam: reflect.New(methodType.In(2).Elem()).Interface(),
}
}