MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / TEST_F

Function TEST_F

test/tests/NetworkTests.cpp:129–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127};
128
129TEST_F(NetworkTests, MapRequestWithoutPlayerDisconnectsAndDoesNotCrash)
130{
131 NetworkBase network(*_context);
132
133 Connection connection;
134 auto mockSocket = std::make_unique<MockTcpSocket>();
135 connection.socket = std::move(mockSocket);
136 connection.authStatus = Auth::none;
137 connection.player = nullptr;
138
139 Packet packet(Command::mapRequest);
140 packet << static_cast<uint32_t>(0); // 0 objects
141
142 // Before the fix, this would crash because it accesses connection.player->Name
143 // After the fix, it should detect connection.player == nullptr and disconnect.
144 network.ServerHandleMapRequest(connection, packet);
145
146 EXPECT_TRUE(connection.shouldDisconnect);
147}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected