summaryrefslogtreecommitdiffstats
path: root/net/quic
diff options
context:
space:
mode:
authorwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-20 02:49:10 +0000
committerwtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-20 02:49:10 +0000
commitc1b32c6f3d09cb7ab47309eb90b7c31bc828dd0c (patch)
tree1bd6da1bc915a0f90beab01e6c2a66446c4adb58 /net/quic
parentff7807ecd6c6ecebb3e5060db0e762709965085c (diff)
downloadchromium_src-c1b32c6f3d09cb7ab47309eb90b7c31bc828dd0c.zip
chromium_src-c1b32c6f3d09cb7ab47309eb90b7c31bc828dd0c.tar.gz
chromium_src-c1b32c6f3d09cb7ab47309eb90b7c31bc828dd0c.tar.bz2
Teach gtest how to print QuicConsumedData and QuicEncryptedPacket.
R=rch@chromium.org,glider@chromium.org BUG=170327 TEST=net_unittests has no unitialized memory errors. Review URL: https://chromiumcodereview.appspot.com/11973021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177869 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic')
-rw-r--r--net/quic/quic_protocol.cc13
-rw-r--r--net/quic/quic_protocol.h15
2 files changed, 27 insertions, 1 deletions
diff --git a/net/quic/quic_protocol.cc b/net/quic/quic_protocol.cc
index 37ba15e4..90a5dab 100644
--- a/net/quic/quic_protocol.cc
+++ b/net/quic/quic_protocol.cc
@@ -79,7 +79,7 @@ QuicAckFrame::QuicAckFrame(QuicPacketSequenceNumber largest_observed,
}
ostream& operator<<(ostream& os, const SentPacketInfo& sent_info) {
- os << "least_waiting: " << sent_info.least_unacked;
+ os << "least_unacked: " << sent_info.least_unacked;
return os;
}
@@ -169,4 +169,15 @@ QuicData::~QuicData() {
}
}
+ostream& operator<<(ostream& os, const QuicEncryptedPacket& s) {
+ os << s.length() << "-byte data";
+ return os;
+}
+
+ostream& operator<<(ostream& os, const QuicConsumedData& s) {
+ os << "bytes_consumed: " << s.bytes_consumed
+ << " fin_consumed: " << s.fin_consumed;
+ return os;
+}
+
} // namespace net
diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h
index a391421..bc486dc 100644
--- a/net/quic/quic_protocol.h
+++ b/net/quic/quic_protocol.h
@@ -479,6 +479,13 @@ class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData {
QuicEncryptedPacket(char* buffer, size_t length, bool owns_buffer)
: QuicData(buffer, length, owns_buffer) { }
+ // By default, gtest prints the raw bytes of an object. The bool data
+ // member (in the base class QuicData) causes this object to have padding
+ // bytes, which causes the default gtest object printer to read
+ // uninitialize memory. So we need to teach gtest how to print this object.
+ NET_EXPORT_PRIVATE friend std::ostream& operator<<(
+ std::ostream& os, const QuicEncryptedPacket& s);
+
base::StringPiece AssociatedData() const {
return base::StringPiece(data() + kStartOfHashData, kStartOfEncryptedData);
}
@@ -495,6 +502,14 @@ struct QuicConsumedData {
: bytes_consumed(bytes_consumed),
fin_consumed(fin_consumed) {
}
+
+ // By default, gtest prints the raw bytes of an object. The bool data
+ // member causes this object to have padding bytes, which causes the
+ // default gtest object printer to read uninitialize memory. So we need
+ // to teach gtest how to print this object.
+ NET_EXPORT_PRIVATE friend std::ostream& operator<<(
+ std::ostream& os, const QuicConsumedData& s);
+
size_t bytes_consumed;
bool fin_consumed;
};