Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: extensions/common/url_pattern_set_unittest.cc

Issue 300573002: Add stream operators for URLPattern and URLPatternSet and unit test for URLPatternSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src@permissions
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/common/url_pattern_set_unittest.cc
diff --git a/extensions/common/url_pattern_set_unittest.cc b/extensions/common/url_pattern_set_unittest.cc
index 267743a77435afc36e66b9978e1f371639c55cf4..eba48694f05bb8fc78f207fb80f75917f5b4e8d5 100644
--- a/extensions/common/url_pattern_set_unittest.cc
+++ b/extensions/common/url_pattern_set_unittest.cc
@@ -60,6 +60,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_STREQ("{ }", stream.str().c_str());
Jeffrey Yasskin 2014/05/28 21:06:08 You can use EXPECT_EQ("{ }", stream.str());
aboxhall 2014/05/28 22:06:44 Done.
+}
+
+TEST(URLPatternSetTest, StreamOperatorOne) {
+ URLPatternSet set;
+ AddPattern(&set, "http://www.google.com/*");
+
+ std::ostringstream stream;
+ stream << set;
+ EXPECT_STREQ("{ \"http://www.google.com/*\" }", stream.str().c_str());
+}
+
+TEST(URLPatternSetTest, StreamOperatorTwo) {
+ URLPatternSet set;
+ AddPattern(&set, "http://www.google.com/*");
+ AddPattern(&set, "http://www.yahoo.com/*");
+
+ std::ostringstream stream;
+ stream << set;
+ EXPECT_STREQ("{ \"http://www.google.com/*\", \"http://www.yahoo.com/*\" }",
+ stream.str().c_str());
+}
+
TEST(URLPatternSetTest, OverlapsWith) {
URLPatternSet set1;
AddPattern(&set1, "http://www.google.com/f*");
« extensions/common/url_pattern_set.cc ('K') | « extensions/common/url_pattern_set.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698