From 7611bd2aeeb5c29ccfed6a1e8d5cb0e17b8c6aac Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Mon, 12 Aug 2024 14:37:07 +0200 Subject: wip --- modules/remote/tests/remote_loopback.cpp | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'modules/remote/tests/remote_loopback.cpp') diff --git a/modules/remote/tests/remote_loopback.cpp b/modules/remote/tests/remote_loopback.cpp index 6ecf4e0..eca107f 100644 --- a/modules/remote/tests/remote_loopback.cpp +++ b/modules/remote/tests/remote_loopback.cpp @@ -26,6 +26,83 @@ SAW_TEST("Remote Loopback Data"){ remote rmt; + using Schema = sch::Array; + + auto eov = rmt.parse_address(0u); + SAW_EXPECT(eov.is_value(), "Didn't parse correctly"); + auto& addr = eov.get_value(); + + auto eo_srv = rmt.template data_listen(*addr); + SAW_EXPECT(eo_srv.is_value(), std::string{"Couldn't listen: "} + std::string{eo_srv.get_error().get_category()}); + auto& srv = eo_srv.get_value(); + + auto cvr_client = rmt.template data_connect(*addr); + auto eo_client = cvr_client.take(); + SAW_EXPECT(eo_client.is_value(), "Couldn't connect."); + auto& client = eo_client.get_value(); + + data foo{4}; + for(uint64_t i = 0; i < foo.size(); ++i){ + foo.at(i).set(i * 2.0); + } + id sent_id = [&](){ + auto eov = client.send(foo); + SAW_EXPECT(eov.is_value(), "Failed send."); + return eov.get_value(); + }(); + + { + 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.is_valid(), "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."); + } + + id alloc_id = [&](){ + auto eov = client.allocate(data>{{4}}); + SAW_EXPECT(eov.is_value(), "Failed send."); + return eov.get_value(); + }(); + { + auto eov = client.find(alloc_id); + SAW_EXPECT(eov.is_value(), "Failed find."); + auto& f_val = eov.get_value(); + // SAW_EXPECT(f_val.is_valid(), "Nullptr in find."); + // f_val->set(5u); + } + { + auto conv = client.receive(alloc_id); + auto eov = conv.take(); + SAW_EXPECT(eov.is_value(), "Failed receive."); + SAW_EXPECT(eov.get_value().size() == 4u, "Wrong received value."); + } +} + +SAW_TEST("Remote Loopback Grouped Data"){ + using namespace saw; + + event_loop loop; + wait_scope wait{loop}; + + remote rmt; + auto eov = rmt.parse_address(0u); SAW_EXPECT(eov.is_value(), "Didn't parse correctly"); auto& addr = eov.get_value(); -- cgit v1.2.3