Skip to content

Commit

Permalink
Added unit tests for SSLServer::bind_to_any_port
Browse files Browse the repository at this point in the history
  • Loading branch information
yhirose committed Feb 15, 2020
1 parent 3fe13ec commit d61d63d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/test.cc
Expand Up @@ -645,10 +645,21 @@ TEST(HttpsToHttpRedirectTest, Redirect) {

TEST(Server, BindAndListenSeparately) {
Server svr;
int port = svr.bind_to_any_port("localhost");
int port = svr.bind_to_any_port("0.0.0.0");
ASSERT_TRUE(svr.is_valid());
ASSERT_TRUE(port > 0);
svr.stop();
}

#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
TEST(SSLServer, BindAndListenSeparately) {
SSLServer svr(SERVER_CERT_FILE, SERVER_PRIVATE_KEY_FILE, CLIENT_CA_CERT_FILE, CLIENT_CA_CERT_DIR);
int port = svr.bind_to_any_port("0.0.0.0");
ASSERT_TRUE(svr.is_valid());
ASSERT_TRUE(port > 0);
svr.stop();
}
#endif

class ServerTest : public ::testing::Test {
protected:
Expand Down

0 comments on commit d61d63d

Please sign in to comment.