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

Issue 2704483002: Add a PrintTo function for rtc::Optional to aid with testing. (Closed)

Created:
3 years, 10 months ago by ossu
Modified:
3 years, 10 months ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, kjellander_webrtc
Target Ref:
refs/heads/master
Project:
webrtc
Visibility:
Public.

Description

Add a PrintTo function for rtc::Optional to aid with testing. gtest can print objects if they have an operator<< or a PrintTo function in the same namespace as the object's class. Since std::optional does not seem to have an operator<<, it'd be preferable not to rely on rtc::Optional being printable through operator<<. Currently, gtest errors will just dump the raw bytes of rtc::Optionals, which make them really annoying to work with in tests. BUG=webrtc:7196 Review-Url: https://codereview.webrtc.org/2704483002 Cr-Commit-Position: refs/heads/master@{#16717} Committed: https://chromium.googlesource.com/external/webrtc/+/e5c27a5db6dab92176f90c4a0cd5a77c6d166a58

Patch Set 1 #

Total comments: 16

Patch Set 2 : Clarified description, removed constructors, made PrintTo safer for sanitizers, removed static_assert #

Patch Set 3 : Added a const variant of FunctionThatDoesNothing. #

Patch Set 4 : Reworked PrintTo so that it's always implemented, or gtest will print out uninitialized bytes. #

Total comments: 7

Patch Set 5 : Added workaround for unused functions; removed attribute((unused)) #

Patch Set 6 : Moved OptionalPrintObjectBytes into optional.h, added an #ifdef UNIT_TEST. #

Total comments: 8

Patch Set 7 : Removed unnecessary stuff. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+156 lines, -1 line) Patch
M webrtc/base/optional.h View 1 2 3 4 5 6 3 chunks +100 lines, -1 line 0 comments Download
M webrtc/base/optional_unittest.cc View 1 2 3 4 2 chunks +56 lines, -0 lines 0 comments Download

Messages

Total messages: 56 (31 generated)
ossu
More reviews! \o/ https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h#newcode305 webrtc/base/optional.h:305: -> decltype(static_cast<void>(*os << *opt)) { The ...
3 years, 10 months ago (2017-02-16 13:20:06 UTC) #3
kwiberg-webrtc
https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h#newcode305 webrtc/base/optional.h:305: -> decltype(static_cast<void>(*os << *opt)) { On 2017/02/16 13:20:05, ossu ...
3 years, 10 months ago (2017-02-16 14:07:38 UTC) #8
ossu
https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h#newcode304 webrtc/base/optional.h:304: auto PrintTo(const Optional<T>& opt, std::ostream* os) Turns out the ...
3 years, 10 months ago (2017-02-16 14:23:48 UTC) #9
kwiberg-webrtc
https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional_unittest.cc File webrtc/base/optional_unittest.cc (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional_unittest.cc#newcode767 webrtc/base/optional_unittest.cc:767: static_assert(std::is_same<void, decltype(PrintTo(empty_printable, On 2017/02/16 14:23:48, ossu wrote: > On ...
3 years, 10 months ago (2017-02-16 14:33:33 UTC) #10
ossu
I've reworked PrintTo so that gtest shouldn't accidentally try to print uninitialized bytes. I was ...
3 years, 10 months ago (2017-02-17 13:32:36 UTC) #23
tommi
https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h#newcode304 webrtc/base/optional.h:304: auto PrintTo(const Optional<T>& opt, std::ostream* os) Can we call ...
3 years, 10 months ago (2017-02-17 13:46:23 UTC) #25
ossu
https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/1/webrtc/base/optional.h#newcode304 webrtc/base/optional.h:304: auto PrintTo(const Optional<T>& opt, std::ostream* os) On 2017/02/17 13:46:23, ...
3 years, 10 months ago (2017-02-17 13:50:06 UTC) #26
kwiberg-webrtc
It would be nice if we could have these test-only things in a separate target, ...
3 years, 10 months ago (2017-02-17 13:50:17 UTC) #27
kwiberg-webrtc
https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc File webrtc/base/optional.cc (right): https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc#newcode34 webrtc/base/optional.cc:34: } This is just for testing, so you should ...
3 years, 10 months ago (2017-02-17 13:51:22 UTC) #28
kwiberg-webrtc
On 2017/02/17 13:50:17, kwiberg-webrtc wrote: > It would be nice if we could have these ...
3 years, 10 months ago (2017-02-17 13:57:01 UTC) #29
ossu
On 2017/02/17 13:50:17, kwiberg-webrtc wrote: > It would be nice if we could have these ...
3 years, 10 months ago (2017-02-17 14:02:20 UTC) #30
tommi
https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc File webrtc/base/optional.cc (right): https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc#newcode34 webrtc/base/optional.cc:34: } On 2017/02/17 14:02:19, ossu wrote: > On 2017/02/17 ...
3 years, 10 months ago (2017-02-17 14:08:55 UTC) #31
ossu
On 2017/02/17 14:08:55, tommi (webrtc) wrote: > https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc > File webrtc/base/optional.cc (right): > > https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc#newcode34 ...
3 years, 10 months ago (2017-02-17 15:06:53 UTC) #32
tommi
On 2017/02/17 15:06:53, ossu wrote: > On 2017/02/17 14:08:55, tommi (webrtc) wrote: > > https://codereview.webrtc.org/2704483002/diff/60001/webrtc/base/optional.cc ...
3 years, 10 months ago (2017-02-17 15:47:26 UTC) #37
ossu
On 2017/02/17 15:47:26, tommi (webrtc) wrote: > What you've done so far works for me. ...
3 years, 10 months ago (2017-02-17 15:49:56 UTC) #38
kwiberg-webrtc
https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h#newcode18 webrtc/base/optional.h:18: #ifdef UNIT_TEST Who defines this? I couldn't find it ...
3 years, 10 months ago (2017-02-18 18:50:47 UTC) #39
kjellander_webrtc
https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h#newcode18 webrtc/base/optional.h:18: #ifdef UNIT_TEST On 2017/02/18 18:50:47, kwiberg-webrtc wrote: > Who ...
3 years, 10 months ago (2017-02-19 09:29:20 UTC) #41
kwiberg-webrtc
https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h#newcode18 webrtc/base/optional.h:18: #ifdef UNIT_TEST On 2017/02/19 09:29:19, kjellander_webrtc wrote: > On ...
3 years, 10 months ago (2017-02-19 13:14:15 UTC) #42
kjellander_webrtc
https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h File webrtc/base/optional.h (right): https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.h#newcode18 webrtc/base/optional.h:18: #ifdef UNIT_TEST On 2017/02/19 13:14:15, kwiberg-webrtc wrote: > On ...
3 years, 10 months ago (2017-02-20 07:24:20 UTC) #43
ossu
Alright. Anything else I've missed or are we fine with this? The two failing bots ...
3 years, 10 months ago (2017-02-20 11:02:24 UTC) #44
kwiberg-webrtc
Oh, right, I never stamped this. lgtm! https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.cc File webrtc/base/optional.cc (right): https://codereview.webrtc.org/2704483002/diff/90001/webrtc/base/optional.cc#newcode23 webrtc/base/optional.cc:23: This extra ...
3 years, 10 months ago (2017-02-20 11:45:32 UTC) #45
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2704483002/110001
3 years, 10 months ago (2017-02-20 11:50:54 UTC) #48
commit-bot: I haz the power
Try jobs failed on following builders: presubmit on master.tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/presubmit/builds/13742)
3 years, 10 months ago (2017-02-20 11:55:44 UTC) #50
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/2704483002/110001
3 years, 10 months ago (2017-02-20 12:28:30 UTC) #53
commit-bot: I haz the power
3 years, 10 months ago (2017-02-20 12:41:51 UTC) #56
Message was sent while issue was closed.
Committed patchset #7 (id:110001) as
https://chromium.googlesource.com/external/webrtc/+/e5c27a5db6dab92176f90c4a0...

Powered by Google App Engine
This is Rietveld 408576698