Skip to content

Commit f3688fd

Browse files
committed
test default PassField impl handles output parameters
Tests that output parameter result is captured from server call and added to response.
1 parent 47d79db commit f3688fd

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

test/mp/test/foo.capnp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $Proxy.includeTypes("mp/test/foo-types.h");
1313

1414
interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
1515
add @0 (a :Int32, b :Int32) -> (result :Int32);
16+
addOut @19 (a :Int32, b :Int32, ret :Int32) -> (ret :Int32);
1617
mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32);
1718
pass @2 (arg :FooStruct) -> (result :FooStruct);
1819
raise @3 (arg :FooStruct) -> (error :FooStruct $Proxy.exception("mp::test::FooStruct"));

test/mp/test/foo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class FooImplementation
6262
{
6363
public:
6464
int add(int a, int b) { return a + b; }
65+
void addOut(int a, int b, int& out) { out = a + b; }
6566
int mapSize(const std::map<std::string, std::string>& map) { return map.size(); }
6667
FooStruct pass(FooStruct foo) { return foo; }
6768
void raise(FooStruct foo) { throw foo; }

test/mp/test/test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ KJ_TEST("Call FooInterface methods")
113113
ProxyClient<messages::FooInterface>* foo = setup.client.get();
114114

115115
KJ_EXPECT(foo->add(1, 2) == 3);
116+
int ret;
117+
foo->addOut(3, 4, ret);
118+
KJ_EXPECT(ret == 7);
116119

117120
FooStruct in;
118121
in.name = "name";

0 commit comments

Comments
 (0)