浏览代码

Added a unit test

yhirose 5 年之前
父节点
当前提交
15c4106a36
共有 1 个文件被更改,包括 14 次插入0 次删除
  1. 14 0
      test/test.cc

+ 14 - 0
test/test.cc

@@ -394,6 +394,20 @@ TEST(ConnectionErrorTest, InvalidHost) {
   ASSERT_TRUE(res == nullptr);
   ASSERT_TRUE(res == nullptr);
 }
 }
 
 
+TEST(ConnectionErrorTest, InvalidHost2) {
+  auto host = "httpbin.org/";
+
+#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
+  httplib::SSLClient cli(host);
+#else
+  httplib::Client cli(host);
+#endif
+  cli.set_connection_timeout(2);
+
+  auto res = cli.Get("/");
+  ASSERT_TRUE(res == nullptr);
+}
+
 TEST(ConnectionErrorTest, InvalidPort) {
 TEST(ConnectionErrorTest, InvalidPort) {
   auto host = "localhost";
   auto host = "localhost";