summaryrefslogtreecommitdiff
path: root/modules/codec/tests/remote_loopback.cpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-07-05 16:50:33 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-07-05 16:50:33 +0200
commit614d0bf07789457a97d194c4af9cc7393f871351 (patch)
treefffe8f702589603b397497e14ca217428c98edec /modules/codec/tests/remote_loopback.cpp
parent9f320474f1c19861d46f6c42a09f7bba9dc919bc (diff)
Working on loopback data transmission
Diffstat (limited to 'modules/codec/tests/remote_loopback.cpp')
-rw-r--r--modules/codec/tests/remote_loopback.cpp51
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.");
+ }
}
}