#include #include "../c++/remote_loopback.hpp" namespace { namespace sch { using namespace saw::schema; using TestInterface = Interface< Member, "foo"> >; } SAW_TEST("Remote Loopback Data"){ using namespace saw; event_loop loop; wait_scope wait{loop}; 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().get(); ++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().get() == 4u, "Wrong received value."); } } }