Pretty print AlternativeService in test macros.
Implement PrintTo(const AlternativeService&, std::ostream*) so that when
EXPECT_EQ or ASSERT_EQ fails between two AlternativeService structs, the test
output contains protocol names and hostnames pretty printed, instead of a binary
blob including useless things like the memory address of where std::string
stores the hostname. See src/testing/gtest/include/gtest/gtest-printers.h for
Currently used in AlternateProtocolServerPropertiesTest.BrokenShadowsCanonical
only, but more tests involving EXPECT_EQ between AlternativeService structs are
An earlier version of this CL landed at https://crrev.com/1212813006 and got
reverted because on iOS, the helper function required registering an ataxit
handler. This version does things differently by
* using PrintTo instead of operator<<, just because this is listed first in the
comments in gtest-printers.h;
* defining the function in http_server_properties_impl_unittests.cc instead of
declaring it in http_server_properties.h with NET_EXPORT, this will make sure
that no static initializers will be introduced.
Note, however, that this helper function cannot be defined in anonymous
namespace, gtest would not find it there.
Review URL: https://codereview.chromium.org/1213133003
1 file changed