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

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: rebase Created 6 years, 5 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
« no previous file with comments | « extensions/common/url_pattern_set.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1ad223ec53ac86db9deacef6d258330d7ceac03b 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*");
« no previous file with comments | « extensions/common/url_pattern_set.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698