Browse Source

Added a unit test for URL interface

yhirose 5 years ago
parent
commit
2b7a968468
1 changed files with 13 additions and 0 deletions
  1. 13 0
      test/test.cc

+ 13 - 0
test/test.cc

@@ -649,6 +649,19 @@ TEST(YahooRedirectTest, Redirect) {
   EXPECT_EQ(200, res->status);
 }
 
+TEST(YahooRedirectTestWithURL, Redirect) {
+  auto res = httplib::url::Get("http://yahoo.com");
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(301, res->status);
+
+  httplib::url::options options;
+  options.follow_location = true;
+
+  res = httplib::url::Get("http://yahoo.com", options);
+  ASSERT_TRUE(res != nullptr);
+  EXPECT_EQ(200, res->status);
+}
+
 TEST(HttpsToHttpRedirectTest, Redirect) {
   httplib::SSLClient cli("httpbin.org");
   cli.set_follow_location(true);