Skip to content

Commit 905b658

Browse files
fix tests net and server
also disable _CRT_SECURE_NO_WARNINGS for test target
1 parent 1b7d7fc commit 905b658

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ if (WIN32)
151151
target_compile_definitions(${GAME_TARGET} PRIVATE
152152
_CRT_SECURE_NO_WARNINGS # no snprintf_s BS warnings
153153
)
154+
if (BUILD_TESTS)
155+
target_compile_definitions(${TEST_TARGET} PRIVATE
156+
_CRT_SECURE_NO_WARNINGS # no snprintf_s BS warnings
157+
)
158+
endif()
154159
endif()
155160

156161
set(APP_PARENT_DIR "$<TARGET_FILE_DIR:${GAME_TARGET}>")

game/tests/net.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ class SsockCtlDummy final : public ServerSocketController {
582582
public:
583583
bool incoming(ServerSocket&, const Peer&) override { return true; }
584584
void dropped(ServerSocket&, const Peer&) override {}
585+
void started() override {}
585586
void stopped() override {}
586587

587588
int proper_packet(ServerSocket&, const std::deque<uint8_t> &q) {
@@ -595,6 +596,7 @@ class SsockCtlEcho final : public ServerSocketController {
595596
public:
596597
bool incoming(ServerSocket&, const Peer&) override { return true; }
597598
void dropped(ServerSocket&, const Peer&) override {}
599+
void started() override {}
598600
void stopped() override {}
599601

600602
int proper_packet(ServerSocket&, const std::deque<uint8_t> &q) {

game/tests/server.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TEST_F(NoUnixOrTracyFixture, serverCreateFail) {
2525

2626
TEST_F(NoUnixOrTracyFixture, clientCreateFail) {
2727
try {
28-
Client c;
28+
Client c("");
2929
(void)c;
3030
FAIL() << "client created with no network subsystem";
3131
} catch (std::runtime_error&) {}
@@ -52,20 +52,20 @@ static void f(Server &s) {
5252
}
5353

5454
TEST_F(ServerFixture, initDelete) {
55-
Client c;
55+
Client c("");
5656
(void)c;
5757
}
5858

5959
TEST_F(ServerFixture, clientStopEarly) {
60-
Client c;
60+
Client c("");
6161
c.stop();
6262
}
6363

6464
static void connect_test(bool close) {
6565
Server s;
6666
std::thread t1([&] { s.mainloop(default_port, 0, true); if (close) s.close(); });
6767

68-
Client c;
68+
Client c("");
6969
c.start(default_host, default_port, false);
7070

7171
char buf[64];
@@ -106,7 +106,7 @@ TEST_F(ServerFixture, connectTests) {
106106
}
107107

108108
TEST_F(ServerFixture, connectTooEarly) {
109-
Client c;
109+
Client c("");
110110

111111
try {
112112
c.start(default_host, default_port, false);
@@ -122,7 +122,7 @@ TEST_F(ServerFixture, connectTooLate) {
122122
s.close();
123123

124124
try {
125-
Client c;
125+
Client c("");
126126
c.start(default_host, default_port, false);
127127

128128
char buf[64];
@@ -157,7 +157,7 @@ static void echo_test(std::vector<std::string> &bt, bool close) {
157157
Server s;
158158
std::thread t1([&] { s.mainloop(default_port, 1, true); if (close) s.close(); });
159159

160-
Client c;
160+
Client c("");
161161
c.start(default_host, default_port, false);
162162

163163
handshake(c);
@@ -183,7 +183,7 @@ TEST_F(ServerFixture, protocol) {
183183
Server s;
184184
std::thread t1([&] { s.mainloop(default_port, 1, true); s.close(); });
185185

186-
Client c;
186+
Client c("");
187187
uint16_t prot;
188188

189189
c.start(default_host, default_port, false);

0 commit comments

Comments
 (0)