diff options
author | aboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 22:40:39 +0000 |
---|---|---|
committer | aboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-09 22:40:39 +0000 |
commit | a601619860e81bc299bb4356a14f05420293fd22 (patch) | |
tree | cf665964ce76b9a978b51225a4208bd710eb4133 /extensions/common/url_pattern_set_unittest.cc | |
parent | 69a3301ce8dbc43705ff1b25287bd6e8bfcc7575 (diff) | |
download | chromium_src-a601619860e81bc299bb4356a14f05420293fd22.zip chromium_src-a601619860e81bc299bb4356a14f05420293fd22.tar.gz chromium_src-a601619860e81bc299bb4356a14f05420293fd22.tar.bz2 |
Add stream operators for URLPattern and URLPatternSet and unit test for URLPatternSet
BUG=
Review URL: https://codereview.chromium.org/300573002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282150 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/url_pattern_set_unittest.cc')
-rw-r--r-- | extensions/common/url_pattern_set_unittest.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/extensions/common/url_pattern_set_unittest.cc b/extensions/common/url_pattern_set_unittest.cc index 267743a7..1ad223e 100644 --- a/extensions/common/url_pattern_set_unittest.cc +++ b/extensions/common/url_pattern_set_unittest.cc @@ -4,6 +4,8 @@ #include "extensions/common/url_pattern_set.h" +#include <sstream> + #include "base/values.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -60,6 +62,34 @@ TEST(URLPatternSetTest, Two) { EXPECT_FALSE(set.MatchesURL(GURL("https://www.apple.com/monkey"))); } +TEST(URLPatternSetTest, StreamOperatorEmpty) { + URLPatternSet set; + + std::ostringstream stream; + stream << set; + EXPECT_EQ("{ }", stream.str()); +} + +TEST(URLPatternSetTest, StreamOperatorOne) { + URLPatternSet set; + AddPattern(&set, "http://www.google.com/*"); + + std::ostringstream stream; + stream << set; + EXPECT_EQ("{ \"http://www.google.com/*\" }", stream.str()); +} + +TEST(URLPatternSetTest, StreamOperatorTwo) { + URLPatternSet set; + AddPattern(&set, "http://www.google.com/*"); + AddPattern(&set, "http://www.yahoo.com/*"); + + std::ostringstream stream; + stream << set; + EXPECT_EQ("{ \"http://www.google.com/*\", \"http://www.yahoo.com/*\" }", + stream.str()); +} + TEST(URLPatternSetTest, OverlapsWith) { URLPatternSet set1; AddPattern(&set1, "http://www.google.com/f*"); |