diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index 31736452..cec38884 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -55,10 +55,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") { @@ -81,3 +82,8 @@ 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..5f213cba 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, }; 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);