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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/base/optional.h" 11 #include "webrtc/base/optional.h"
12 12
13 #include <iomanip>
14
13 namespace rtc { 15 namespace rtc {
14 namespace optional_internal { 16 namespace optional_internal {
15 17
16 #if RTC_HAS_ASAN 18 #if RTC_HAS_ASAN
17 19
18 void* FunctionThatDoesNothingImpl(void* x) { return x; } 20 void* FunctionThatDoesNothingImpl(void* x) { return x; }
19 21
20 #endif 22 #endif
21 23
24 void OptionalPrintObjectBytes(const unsigned char* bytes,
25 size_t size,
26 std::ostream* os) {
27 *os << "<optional with " << size << "-byte object [";
28 for (size_t i = 0; i != size; ++i) {
29 *os << (i == 0 ? "" : ((i & 1) ? "-" : " "));
30 *os << std::hex << std::setw(2) << std::setfill('0')
31 << static_cast<int>(bytes[i]);
32 }
33 *os << "]>";
34 }
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
35
22 } // namespace optional_internal 36 } // namespace optional_internal
37
23 } // namespace rtc 38 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698