src/lib/url/gurl_unittest.cc
// Test the basic creation and querying of components in a GURL. We assume that
// the parser is already tested and works, so we are mostly interested if the
// object does the right thing with the results.
Test the basic creation and querying of components in a GURL. We assume that
the parser is already tested and works, so we are mostly interested if the
object does the right thing with the results.
Test the basic creation and querying of components in a GURL . We assume that the parser is already tested and works so we are mostly interested if the object does the right thing with the results .
TEST(GURLTest, Components) {
  GURL url("http://user:pass@google.com:99/foo;bar?q=a#ref");
  EXPECT_TRUE(url.is_valid());
  EXPECT_TRUE(url.SchemeIs("http"));
  EXPECT_FALSE(url.SchemeIsFile());
  EXPECT_EQ("http", url.scheme());
  EXPECT_EQ("user", url.username());
  EXPECT_EQ("pass", url.password());
  EXPECT_EQ("google.com", url.host());
  EXPECT_EQ("99", url.port());
  EXPECT_EQ(99, url.IntPort());
  EXPECT_EQ("/foo;bar", url.path());
  EXPECT_EQ("q=a", url.query());
  EXPECT_EQ("ref", url.ref());
  GURL url_special_pass("http://user:%40!$&'()*+,;=:@google.com:12345");
  EXPECT_TRUE(url_special_pass.is_valid());
  EXPECT_EQ("%40!$&%27()*+,%3B%3D%3A", url_special_pass.password());
  EXPECT_EQ("google.com", url_special_pass.host());
  EXPECT_EQ("12345", url_special_pass.port());
}
TEST ( GURLTest , Components ) { GURL url ( " " ) ; EXPECT_TRUE ( url . is_valid ( ) ) ; EXPECT_TRUE ( url . SchemeIs ( " " ) ) ; EXPECT_FALSE ( url . SchemeIsFile ( ) ) ; EXPECT_EQ ( " " , url . scheme ( ) ) ; EXPECT_EQ ( " " , url . username ( ) ) ; EXPECT_EQ ( " " , url . password ( ) ) ; EXPECT_EQ ( " " , url . host ( ) ) ; EXPECT_EQ ( " " , url . port ( ) ) ; EXPECT_EQ ( 99 , url . IntPort ( ) ) ; EXPECT_EQ ( " " , url . path ( ) ) ; EXPECT_EQ ( " " , url . query ( ) ) ; EXPECT_EQ ( " " , url . ref ( ) ) ; GURL url_special_pass ( " " ) ; EXPECT_TRUE ( url_special_pass . is_valid ( ) ) ; EXPECT_EQ ( " " , url_special_pass . password ( ) ) ; EXPECT_EQ ( " " , url_special_pass . host ( ) ) ; EXPECT_EQ ( " " , url_special_pass . port ( ) ) ; }
Test the basic creation and querying of components in a GURL.
Test the basic creation and querying of components in a GURL .
// Test parsing userinfo with special characters. // GURL canonicalizes some delimiters.