diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index 31736452..ba8c6993 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -15,7 +15,6 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") { add @0 (a :Int32, b :Int32) -> (result :Int32); addOut @19 (a :Int32, b :Int32) -> (ret :Int32); addInOut @20 (x :Int32, sum :Int32) -> (sum :Int32); - mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32); pass @2 (arg :FooStruct) -> (result :FooStruct); raise @3 (arg :FooStruct) -> (error :FooStruct $Proxy.exception("mp::test::FooStruct")); initThreadMap @4 (threadMap: Proxy.ThreadMap) -> (threadMap :Proxy.ThreadMap); @@ -30,7 +29,7 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") { passMessage @13 (arg :FooMessage) -> (result :FooMessage); passMutable @14 (arg :FooMutable) -> (arg :FooMutable); passEnum @15 (arg :Int32) -> (result :Int32); - passDouble @23 (arg :Float64) -> (result :Float64); + passDouble @1 (arg :Float64) -> (result :Float64); passFn @16 (context :Proxy.Context, fn :FooFn) -> (result :Int32); callFn @17 () -> (); callFnAsync @18 (context :Proxy.Context) -> (); @@ -55,10 +54,11 @@ interface FooFn $Proxy.wrap("ProxyCallback>") { struct FooStruct $Proxy.wrap("mp::test::FooStruct") { name @0 :Text; setInt @1 :List(Int32) $Proxy.name("set_int"); - vBool @2 :List(Bool) $Proxy.name("v_bool"); + vectorBool @2 :List(Bool) $Proxy.name("vector_bool"); optionalInt @3 :Int32 $Proxy.name("optional_int"); hasOptionalInt @4 :Bool; unorderedSetInt @5 :List(Int32) $Proxy.name("unordered_set_int"); + mapStringInt @6 :List(StringIntPair) $Proxy.name("map_string_int"); } struct FooCustom $Proxy.wrap("mp::test::FooCustom") { @@ -77,7 +77,7 @@ struct FooMutable { message @0 :Text; } -struct Pair(T1, T2) { - first @0 :T1; - second @1 :T2; +struct StringIntPair { + first @0 :Text; + second @1 :Int32; } diff --git a/test/mp/test/foo.h b/test/mp/test/foo.h index 5b66b85e..fc129eab 100644 --- a/test/mp/test/foo.h +++ b/test/mp/test/foo.h @@ -22,9 +22,10 @@ struct FooStruct { std::string name; std::set set_int; - std::vector v_bool; + std::vector vector_bool; std::optional optional_int; std::unordered_set unordered_set_int; + std::map map_string_int; }; enum class FooEnum : uint8_t { ONE = 1, TWO = 2, }; @@ -71,7 +72,6 @@ class FooImplementation int add(int a, int b) { return a + b; } void addOut(int a, int b, int& out) { out = a + b; } void addInOut(int x, int& sum) { sum += x; } - int mapSize(const std::map& map) { return map.size(); } FooStruct pass(FooStruct foo) { return foo; } void raise(FooStruct foo) { throw foo; } void initThreadMap() {} diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index eb4b5ec7..57ee278c 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -146,10 +147,12 @@ KJ_TEST("Call FooInterface methods") in.set_int.insert(1); in.unordered_set_int.insert(2); in.unordered_set_int.insert(1); - in.v_bool.push_back(false); - in.v_bool.push_back(true); - in.v_bool.push_back(false); + in.vector_bool.push_back(false); + in.vector_bool.push_back(true); + in.vector_bool.push_back(false); in.optional_int = 3; + in.map_string_int.emplace("a", 1); + in.map_string_int.emplace("b", 2); FooStruct out = foo->pass(in); KJ_EXPECT(in.name == out.name); KJ_EXPECT(in.set_int.size() == out.set_int.size()); @@ -160,11 +163,16 @@ KJ_TEST("Call FooInterface methods") for (const auto& elem : in.unordered_set_int) { KJ_EXPECT(out.unordered_set_int.count(elem) == 1); } - KJ_EXPECT(in.v_bool.size() == out.v_bool.size()); - for (size_t i = 0; i < in.v_bool.size(); ++i) { - KJ_EXPECT(in.v_bool[i] == out.v_bool[i]); + KJ_EXPECT(in.vector_bool.size() == out.vector_bool.size()); + for (size_t i = 0; i < in.vector_bool.size(); ++i) { + KJ_EXPECT(in.vector_bool[i] == out.vector_bool[i]); } KJ_EXPECT(in.optional_int == out.optional_int); + KJ_EXPECT(in.map_string_int.size() == out.map_string_int.size()); + for (auto init{in.map_string_int.begin()}, outit{out.map_string_int.begin()}; init != in.map_string_int.end() && outit != out.map_string_int.end(); ++init, ++outit) { + KJ_EXPECT(init->first == outit->first); + KJ_EXPECT(init->second == outit->second); + } // Additional checks for std::optional member KJ_EXPECT(foo->pass(in).optional_int == 3);