Add operator== and operator!=(StringPiece, GURL)
We already have operator==(GURL, StringPiece) and operator!=(GURL,
StringPiece). The CL adds variants with the arguments the other way
around.
Motivation: Compatibility with EXPECT_EQ(expected, actual) in
googletest:
GURL gurl = ...;
EXPECT_EQ("https://www.google.com/", gurl);
Updated the motivating test case in this CL also.
Bug: 655467
Change-Id: I170bdd8c4219fabd324fc596c95a941390ec36cd
Reviewed-on: https://chromium-review.googlesource.com/680854
Commit-Queue: Andrew Moylan <[email protected]>
Reviewed-by: Charlie Harrison <[email protected]>
Reviewed-by: Brett Wilson <[email protected]>
Cr-Commit-Position: refs/heads/master@{#507601}
diff --git a/url/gurl.cc b/url/gurl.cc
index dbf09b8..2132cf2 100644
--- a/url/gurl.cc
+++ b/url/gurl.cc
@@ -557,6 +557,14 @@
return x.possibly_invalid_spec() == spec;
}
+bool operator==(const base::StringPiece& spec, const GURL& x) {
+ return x == spec;
+}
+
bool operator!=(const GURL& x, const base::StringPiece& spec) {
return !(x == spec);
}
+
+bool operator!=(const base::StringPiece& spec, const GURL& x) {
+ return !(x == spec);
+}