MCPcopy Index your code
hub / github.com/Kitware/CMake / TEST

Function TEST

Utilities/cmcppdap/src/socket_test.cpp:25–51  ·  view source on GitHub ↗

Basic socket send & receive test

Source from the content-addressed store, hash-verified

23
24// Basic socket send & receive test
25TEST(Socket, SendRecv) {
26 const char* port = "19021";
27
28 auto server = dap::Socket("localhost", port);
29
30 auto client = dap::Socket::connect("localhost", port, 0);
31 ASSERT_TRUE(client != nullptr);
32
33 const std::string expect = "Hello World!";
34 std::string read;
35
36 auto thread = std::thread([&] {
37 auto conn = server.accept();
38 ASSERT_TRUE(conn != nullptr);
39 char c;
40 while (conn->read(&c, 1) != 0) {
41 read += c;
42 }
43 });
44
45 ASSERT_TRUE(client->write(expect.data(), expect.size()));
46
47 client->close();
48 thread.join();
49
50 ASSERT_EQ(read, expect);
51}
52
53// See https://github.com/google/cppdap/issues/37
54TEST(Socket, CloseOnDifferentThread) {

Callers

nothing calls this directly

Calls 12

connectFunction · 0.85
moveFunction · 0.85
acceptMethod · 0.80
joinMethod · 0.80
emplace_backMethod · 0.80
SocketClass · 0.70
readMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
closeMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…