Commit 38b66fff authored by Benoit Eudier's avatar Benoit Eudier

Refactor listener_test.cc

Should fail if we cannot find a port.
Remove useless comment
parent 4b964416
...@@ -109,8 +109,7 @@ TEST(listener_test, listener_bind_port_free) { ...@@ -109,8 +109,7 @@ TEST(listener_test, listener_bind_port_free) {
if (port_nb == 0) { if (port_nb == 0) {
std::cerr << "Could not find a free port. Abord test.\n"; FAIL() << "Could not find a free port. Abord test.\n";
exit(1);
} }
Pistache::Port port(port_nb); Pistache::Port port(port_nb);
...@@ -129,8 +128,7 @@ TEST(listener_test, listener_bind_port_not_free_throw_runtime) { ...@@ -129,8 +128,7 @@ TEST(listener_test, listener_bind_port_not_free_throw_runtime) {
uint16_t port_nb = s.port(); uint16_t port_nb = s.port();
if (port_nb == 0) { if (port_nb == 0) {
std::cerr << "Could not find a free port. Abord test.\n"; FAIL() << "Could not find a free port. Abord test.\n";
exit(1);
} }
Pistache::Port port(port_nb); Pistache::Port port(port_nb);
...@@ -146,7 +144,6 @@ TEST(listener_test, listener_bind_port_not_free_throw_runtime) { ...@@ -146,7 +144,6 @@ TEST(listener_test, listener_bind_port_not_free_throw_runtime) {
std::cout << err.what() << std::endl; std::cout << err.what() << std::endl;
ASSERT_STREQ("Address already in use", err.what()); ASSERT_STREQ("Address already in use", err.what());
} catch ( ... ) { } catch ( ... ) {
// We are expecting a runtime error
FAIL() << "Expected std::runtime_error"; FAIL() << "Expected std::runtime_error";
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment