MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / run

Method run

source/test/universe_connection_test.cpp:26–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24 }
25
26 virtual void run() {
27 try {
28 unsigned read = 0;
29 unsigned written = 0;
30 while (read < PacketCount || written < PacketCount) {
31 m_connection.receive();
32 if (read < PacketCount) {
33 if (auto packet = m_connection.pullSingle()) {
34 EXPECT_TRUE(convert<ProtocolRequestPacket>(packet)->requestProtocolVersion == read);
35 ++read;
36 }
37 }
38
39 if (written < PacketCount) {
40 m_connection.push({make_shared<ProtocolRequestPacket>(written)});
41 ++written;
42 }
43 m_connection.send();
44
45 Thread::sleep(ASyncSleepMillis);
46
47 if (!m_connection.isOpen())
48 break;
49 }
50
51 EXPECT_EQ(PacketCount, read);
52 EXPECT_EQ(PacketCount, written);
53 m_connection.close();
54 EXPECT_TRUE(m_connection.pull().empty());
55 } catch (std::exception const& e) {
56 ADD_FAILURE() << "Exception: " << outputException(e, true);
57 } catch (...) {
58 ADD_FAILURE();
59 }
60 }
61
62private:
63 UniverseConnection m_connection;

Callers

nothing calls this directly

Calls 9

pullSingleMethod · 0.80
pullMethod · 0.80
outputExceptionFunction · 0.50
receiveMethod · 0.45
pushMethod · 0.45
sendMethod · 0.45
isOpenMethod · 0.45
closeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected