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

Unified Diff: webrtc/base/optional.cc

Issue 2704483002: Add a PrintTo function for rtc::Optional to aid with testing. (Closed)
Patch Set: Reworked PrintTo so that it's always implemented, or gtest will print out uninitialized bytes. Created 3 years, 10 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: webrtc/base/optional.cc
diff --git a/webrtc/base/optional.cc b/webrtc/base/optional.cc
index 6bebdd5a19225fcf46424e97c95d28ccba1b800e..455cfe939a936f9e2f0571d2a5624b42f42f7e55 100644
--- a/webrtc/base/optional.cc
+++ b/webrtc/base/optional.cc
@@ -10,6 +10,8 @@
#include "webrtc/base/optional.h"
+#include <iomanip>
+
namespace rtc {
namespace optional_internal {
@@ -19,5 +21,18 @@ void* FunctionThatDoesNothingImpl(void* x) { return x; }
#endif
+void OptionalPrintObjectBytes(const unsigned char* bytes,
+ size_t size,
+ std::ostream* os) {
+ *os << "<optional with " << size << "-byte object [";
+ for (size_t i = 0; i != size; ++i) {
+ *os << (i == 0 ? "" : ((i & 1) ? "-" : " "));
+ *os << std::hex << std::setw(2) << std::setfill('0')
+ << static_cast<int>(bytes[i]);
+ }
+ *os << "]>";
+}
kwiberg-webrtc 2017/02/17 13:51:22 This is just for testing, so you should probably i
ossu 2017/02/17 14:02:19 I'd rather keep this cruft as isolated as possible
tommi 2017/02/17 14:08:55 My concern is that if we get to the point that we
+
} // namespace optional_internal
+
} // namespace rtc

Powered by Google App Engine
This is Rietveld 408576698