Commit cbf23d74 authored by Benoit Eudier's avatar Benoit Eudier

Add regression test for fixed issue

Regression test should ensure that a non-init listener will not make
the server crash as it used to do.
parent 7d8ffe52
......@@ -123,6 +123,34 @@ TEST(listener_test, listener_bind_port_free) {
ASSERT_TRUE(true);
}
// Listener should not crash if an additional member is added to the listener class. This test
// is there to prevent regression for PR 303
TEST(listener_test, listener_uses_default) {
uint16_t port_nb;
// This is just done to get the value of a free port. The socket will be closed
// after the closing curly bracket and the port will be free again (SO_REUSEADDR option).
// In theory, it is possible that some application grab this port before we bind it again...
{
SocketWrapper s = bind_free_port();
port_nb = s.port();
}
if (port_nb == 0) {
FAIL() << "Could not find a free port. Abord test.\n";
}
Pistache::Port port(port_nb);
Pistache::Address address(Pistache::Ipv4::any(), port);
Pistache::Tcp::Listener listener;
listener.setHandler(Pistache::Http::make_handler<DummyHandler>());
listener.bind(address);
ASSERT_TRUE(true);
}
TEST(listener_test, listener_bind_port_not_free_throw_runtime) {
......
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