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

Unified Diff: base/strings/nullable_string16.h

Issue 17289005: Add support using EXPECT_EQ with NullableString16 objects. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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: base/strings/nullable_string16.h
diff --git a/base/strings/nullable_string16.h b/base/strings/nullable_string16.h
index 73fe81e0842034eba4d918cafeb58dcd8d22f2a0..16dcfe23d38093195c91f9e5b549ebf23079d1e1 100644
--- a/base/strings/nullable_string16.h
+++ b/base/strings/nullable_string16.h
@@ -5,6 +5,9 @@
#ifndef BASE_STRINGS_NULLABLE_STRING16_H_
#define BASE_STRINGS_NULLABLE_STRING16_H_
+#include <iosfwd>
+
+#include "base/base_export.h"
#include "base/strings/string16.h"
namespace base {
@@ -14,7 +17,7 @@ namespace base {
// empty is meaningful.
class NullableString16 {
public:
- NullableString16() : is_null_(false) { }
+ NullableString16() : is_null_(true) { }
explicit NullableString16(bool is_null) : is_null_(is_null) { }
NullableString16(const string16& string, bool is_null)
: string_(string), is_null_(is_null) {
@@ -28,6 +31,17 @@ class NullableString16 {
bool is_null_;
};
+inline bool operator==(const NullableString16& a, const NullableString16& b) {
+ return a.is_null() == b.is_null() && a.string() == b.string();
+}
+
+inline bool operator!=(const NullableString16& a, const NullableString16& b) {
+ return !(a == b);
+}
+
+BASE_EXPORT std::ostream& operator<<(std::ostream& out,
+ const NullableString16& value);
+
} // namespace
// TODO(avi) update users of NullableString16 to use the namespace and remove

Powered by Google App Engine
This is Rietveld 408576698