MCPcopy Create free account
hub / github.com/dfranx/SHADERed / TEST

Function TEST

libs/cppdap/src/network_test.cpp:46–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44} // anonymous namespace
45
46TEST(Network, ClientServer) {
47 const int port = 19021;
48 dap::Chan<bool> done;
49 auto server = dap::net::Server::create();
50 if (!server->start(
51 port,
52 [&](const std::shared_ptr<dap::ReaderWriter>& rw) {
53 ASSERT_EQ(read(rw), "client to server");
54 ASSERT_TRUE(write(rw, "server to client"));
55 done.put(true);
56 },
57 [&](const char* err) { FAIL() << "Server error: " << err; })) {
58 FAIL() << "Couldn't start server";
59 return;
60 }
61
62 for (int i = 0; i < 10; i++) {
63 if (auto client = dap::net::connect("localhost", port)) {
64 ASSERT_TRUE(write(client, "client to server"));
65 ASSERT_EQ(read(client), "server to client");
66 break;
67 }
68 std::this_thread::sleep_for(std::chrono::seconds(1));
69 }
70
71 done.take();
72 server.reset();
73}

Callers

nothing calls this directly

Calls 8

readFunction · 0.85
writeFunction · 0.85
connectFunction · 0.85
startMethod · 0.80
takeMethod · 0.80
createFunction · 0.50
putMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected