adopt the test for augmented Out<> return types. correct return value of stringlist_add(): it does _not_ return the whole list, but the last element. m( JSON-93
authorLars Rohwedder <roker@pep-project.org>
Thu, 17 May 2018 17:16:28 +0200
branchJSON-93
changeset 516ed6ead4b4a62
parent 515 e05b31c647d0
child 518 47c22f1e04e3
adopt the test for augmented Out<> return types. correct return value of stringlist_add(): it does _not_ return the whole list, but the last element. m(
server/unittest_rpc.cc
     1.1 --- a/server/unittest_rpc.cc	Thu May 17 17:15:41 2018 +0200
     1.2 +++ b/server/unittest_rpc.cc	Thu May 17 17:16:28 2018 +0200
     1.3 @@ -48,7 +48,7 @@
     1.4  const FunctionMap test_functions = {
     1.5  		FP( "add_mul_simple", new Func<int, In<int>, In<int>, In<int>>( &add_mul_simple )),
     1.6  		FP( "add_mul_inout", new Func<char*, In<int>, In<c_string>, InOutP<int>, Out<char*>>( &add_mul_inout )),
     1.7 -		FP( "stringlist_add", new Func<stringlist_t*, In<stringlist_t*, DontOwn>, In<c_string>>( &stringlist_add )),
     1.8 +		FP( "stringlist_add", new Func<Out<stringlist_t*, DontOwn>, InOut<stringlist_t*>, In<c_string>>( &stringlist_add )),
     1.9  	};
    1.10  
    1.11  
    1.12 @@ -79,7 +79,7 @@
    1.13  		  "{\"jsonrpc\":\"2.0\", \"id\":23, \"result\":{ \"outParams\":[\"25953\",25953], \"return\":\"x25953x\"}}"
    1.14  		},
    1.15  		{ "{\"jsonrpc\":\"2.0\", \"id\":24, \"method\":\"stringlist_add\", \"params\":[[\"abc\",\"def\"], \"ADD\"]}",
    1.16 -		  "{\"jsonrpc\":\"2.0\", \"id\":24, \"result\":{ \"outParams\":[], \"return\":[\"abc\", \"def\", \"ADD\"]}}"
    1.17 +		  "{\"jsonrpc\":\"2.0\", \"id\":24, \"result\":{ \"outParams\":[[\"abc\", \"def\", \"ADD\"]], \"return\":[\"ADD\"]}}"
    1.18  		},
    1.19  
    1.20  	};
    1.21 @@ -102,18 +102,8 @@
    1.22  
    1.23  	js::Value expected_result;
    1.24  	js::read_or_throw(v.result, expected_result);
    1.25 +	auto r = request;
    1.26  	
    1.27  	const js::Value actual_result = call( test_functions, request.get_obj(), nullptr, false ); // don't check for security token in this unittest
    1.28  	EXPECT_EQ( expected_result, actual_result );
    1.29  }
    1.30 -
    1.31 -
    1.32 -TEST( RpcTest, StringListAdd)
    1.33 -{
    1.34 -	js::Value v;
    1.35 -	js::read_or_throw("[\"abc\", \"def\"]", v);
    1.36 -	
    1.37 -	stringlist_t* sl = from_json<stringlist_t*>( v );
    1.38 -	std::cout << "€€: " << to_json(sl) << std::endl;
    1.39 -	EXPECT_EQ(1,1);
    1.40 -}