MCPcopy Create free account
hub / github.com/Kitware/CMake / TEST

Function TEST

Utilities/cmcppdap/src/network_test.cpp:48–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

writeFunction · 0.85
connectFunction · 0.85
takeMethod · 0.80
readFunction · 0.70
startMethod · 0.45
putMethod · 0.45
resetMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…