teach gtest how to pretty-print StringPiece values
authorAdam Simpkins <simpkins@fb.com>
Fri, 10 Mar 2017 01:54:21 +0000 (17:54 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 10 Mar 2017 02:05:17 +0000 (18:05 -0800)
commit499cf208b86085e7b870843e7e4a2e26c13c1a68
tree7eb4eb7d47cb626ee4fb386f2b4ca8783035488e
parent839b3f3171cefdb81cd189217184975e5fdc70df
teach gtest how to pretty-print StringPiece values

Summary:
Even though an ostream operator<<() is defined for StringPiece, gtest doesn't
use it when printing StringPiece values in test failure messages.  Because
StringPiece defines a nested iterator type gtest instead treats StringPiece as
a container, and prints each of its elements (characters) one-by-one.  This is
fairly awkward to read.

This diff defines an explicit PrintTo() function for StringPiece in
folly/test/TestUtils.h.  This makes gtest print StringPiece values nicely if
you include TestUtils.h in your test sources.

Reviewed By: yfeldblum

Differential Revision: D4672257

fbshipit-source-id: 4b39ccc116e5382c29c37c2abe879293d310faf5
folly/test/TestUtils.h