Skip to content

Commit 6db6696

Browse files
committed
test In|Out parameter
1 parent 29cf2ad commit 6db6696

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

test/mp/test/foo.capnp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $Proxy.includeTypes("mp/test/foo-types.h");
1414
interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
1515
add @0 (a :Int32, b :Int32) -> (result :Int32);
1616
addOut @19 (a :Int32, b :Int32) -> (ret :Int32);
17+
addInOut @20 (x :Int32, sum :Int32) -> (sum :Int32);
1718
mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32);
1819
pass @2 (arg :FooStruct) -> (result :FooStruct);
1920
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
@@ -63,6 +63,7 @@ class FooImplementation
6363
public:
6464
int add(int a, int b) { return a + b; }
6565
void addOut(int a, int b, int& out) { out = a + b; }
66+
void addInOut(int x, int& sum) { sum += x; }
6667
int mapSize(const std::map<std::string, std::string>& map) { return map.size(); }
6768
FooStruct pass(FooStruct foo) { return foo; }
6869
void raise(FooStruct foo) { throw foo; }

test/mp/test/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ KJ_TEST("Call FooInterface methods")
116116
int ret;
117117
foo->addOut(3, 4, ret);
118118
KJ_EXPECT(ret == 7);
119+
foo->addInOut(3, ret);
120+
KJ_EXPECT(ret == 10);
119121

120122
FooStruct in;
121123
in.name = "name";

0 commit comments

Comments
 (0)