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

Unified Diff: net/socket/socket_test_util.cc

Issue 10795012: Modify DeterministicSocketData to verify that the sequence number of reads and writes start at zero… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix sleevi's comments Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.cc
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index ef6d38c2e6c5c67955e5ebb45140ccfdfc32102a..908d2b66f5d133531022a8cc4b1e7f867bf6aa34 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -227,6 +227,30 @@ void StaticSocketDataProvider::Reset() {
write_index_ = 0;
}
+void StaticSocketDataProvider::VerifyCorrectSequenceNumbers() {
+ size_t read = 0;
+ size_t write = 0;
+ int expected = 0;
+ while (read < read_count_ || write < write_count_) {
+ // Check to see that we have a read or write at the expected
+ // state.
+ if (read < read_count_ && reads_[read].sequence_number == expected) {
+ ++read;
+ ++expected;
+ continue;
+ }
+ if (write < write_count_ && writes_[write].sequence_number == expected) {
+ ++write;
+ ++expected;
+ continue;
+ }
+ NOTREACHED() << "Missing sequence number: " << expected;
+ return;
+ }
+ DCHECK_EQ(read, read_count_);
+ DCHECK_EQ(write, write_count_);
+}
+
DynamicSocketDataProvider::DynamicSocketDataProvider()
: short_read_limit_(0),
allow_unconsumed_reads_(false) {
@@ -450,6 +474,7 @@ DeterministicSocketData::DeterministicSocketData(MockRead* reads,
stopping_sequence_number_(0),
stopped_(false),
print_debug_(false) {
+ VerifyCorrectSequenceNumbers();
Ryan Sleevi 2012/07/18 19:14:01 You have access to |reads|, |read_count|, |writes|
Ryan Hamilton 2012/07/18 21:58:20 *facepalm* Duh! Obviously :> Thanks. Done.
}
DeterministicSocketData::~DeterministicSocketData() {}
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/spdy/spdy_network_transaction_spdy2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698