X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ftest%2FUriTest.cpp;h=1431d63da0e74389eb691d0536d41b366a737ec3;hb=7bf1486094cccb266e789a378d8e5f91e3cb7780;hp=7f8faee8847d5ad2728b9f94f104a53407f85a58;hpb=1e5e33a557fc1f2b7f1322b928566fe71bcf26ad;p=folly.git diff --git a/folly/test/UriTest.cpp b/folly/test/UriTest.cpp index 7f8faee8..1431d63d 100644 --- a/folly/test/UriTest.cpp +++ b/folly/test/UriTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,14 @@ */ #include +#include #include #include -#include #include using namespace folly; -namespace { - -} // namespace - TEST(Uri, Simple) { { fbstring s("http://www.facebook.com/hello/world?query#fragment"); @@ -238,7 +234,7 @@ TEST(Uri, Simple) { EXPECT_EQ("/etc/motd", u.path()); EXPECT_EQ("", u.query()); EXPECT_EQ("", u.fragment()); - EXPECT_EQ("file:///etc/motd", u.fbstr()); + EXPECT_EQ("file:/etc/motd", u.fbstr()); } { @@ -351,7 +347,7 @@ TEST(Uri, Simple) { try { Uri u(s); CHECK(false) << "Control should not have reached here"; - } catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument&) { // success } } @@ -362,7 +358,7 @@ TEST(Uri, Simple) { try { Uri u(s); CHECK(false) << "Control should not have reached here"; - } catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument&) { // success } } @@ -373,7 +369,7 @@ TEST(Uri, Simple) { try { Uri u(s); CHECK(false) << "Control should not have reached here"; - } catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument&) { // success } } @@ -384,8 +380,31 @@ TEST(Uri, Simple) { try { Uri u(s); CHECK(false) << "Control should not have reached here"; - } catch (const std::invalid_argument& ex) { + } catch (const std::invalid_argument&) { // success } } + + // No authority (no "//") is valid + { + fbstring s("this:is/a/valid/uri"); + Uri u(s); + EXPECT_EQ("this", u.scheme()); + EXPECT_EQ("is/a/valid/uri", u.path()); + EXPECT_EQ(s, u.fbstr()); + } + { + fbstring s("this:is:another:valid:uri"); + Uri u(s); + EXPECT_EQ("this", u.scheme()); + EXPECT_EQ("is:another:valid:uri", u.path()); + EXPECT_EQ(s, u.fbstr()); + } + { + fbstring s("this:is@another:valid:uri"); + Uri u(s); + EXPECT_EQ("this", u.scheme()); + EXPECT_EQ("is@another:valid:uri", u.path()); + EXPECT_EQ(s, u.fbstr()); + } }