diff options
Diffstat (limited to 'modules/codec/tests')
-rw-r--r-- | modules/codec/tests/remote_loopback.cpp | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/modules/codec/tests/remote_loopback.cpp b/modules/codec/tests/remote_loopback.cpp index 2f6c06c..2895ee7 100644 --- a/modules/codec/tests/remote_loopback.cpp +++ b/modules/codec/tests/remote_loopback.cpp @@ -1,6 +1,6 @@ #include <forstio/test/suite.hpp> -#include "remote_loopback.hpp" +#include "../c++/remote_loopback.hpp" namespace { namespace sch { @@ -9,9 +9,16 @@ using namespace saw::schema; using TestInterface = Interface< Member<Function<UInt32, Int64>, "foo"> >; + +using GroupedSchemas = saw::tmpl_group< + UInt64, + String, + Array<Int32>, + Float64 +>; } -SAW_TEST("Remote Loopback"){ +SAW_TEST("Remote Loopback Data"){ using namespace saw; remote<rmt::Loopback> rmt; @@ -22,9 +29,45 @@ SAW_TEST("Remote Loopback"){ interface<sch::TestInterface, encode::Native, storage::Default> iface{ [](data<sch::UInt32>& foo){ - return foo.template cast<sch::Int64>(); + return foo.template cast_to<sch::Int64>(); } }; - auto rpc_srv = rmt.listen(*val, std::move(iface)); + + auto srv = data_server<sch::GroupedSchemas, encode::Native, rmt::Loopback>{}; + auto client = data_client<sch::GroupedSchemas, encode::Native, rmt::Loopback>{srv}; + + data<sch::UInt64> foo{421}; + id<sch::UInt64> sent_id = [&](){ + auto eov = client.send(foo); + SAW_EXPECT(eov.is_value(), "Failed send."); + return eov.get_value(); + }(); + + event_loop loop; + wait_scope wait{loop}; + + { + auto conv = client.receive(sent_id); + auto eov = conv.take(); + + SAW_EXPECT(eov.is_value(), "Failed receive."); + SAW_EXPECT(eov.get_value() == foo, "Wrong received value."); + } + { + auto eov = client.find(sent_id); + SAW_EXPECT(eov.is_value(), "Failed find."); + auto& f_val = eov.get_value(); + SAW_EXPECT(f_val, "Nullptr in find."); + SAW_EXPECT(*f_val == foo, "Wrong received value."); + } + { + auto eov = client.erase(sent_id); + SAW_EXPECT(eov.is_value(), "Failed erase."); + } + { + auto conv = client.receive(sent_id); + auto eov = conv.take(); + SAW_EXPECT(!eov.is_value(), "Failed receive. Value should already be erased."); + } } } |