diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 00:35:39 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-21 00:35:39 +0000 |
commit | d55b30acf681116affd8ce2cc8deec9cae2e124f (patch) | |
tree | 936ef6f0cfce9e02f5bf33d8c6e3fdc2cd2bfaf0 /net/socket/socket_test_util.cc | |
parent | f98502f4243d2329256f20352148d9cadf38fbdf (diff) | |
download | chromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.zip chromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.tar.gz chromium_src-d55b30acf681116affd8ce2cc8deec9cae2e124f.tar.bz2 |
Modify DeterministicSocketData to verify that the sequence number of reads and writes start at zero and are continuous.
Review URL: https://chromiumcodereview.appspot.com/10795012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socket_test_util.cc')
-rw-r--r-- | net/socket/socket_test_util.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index ff66830..34af370 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -450,6 +450,7 @@ DeterministicSocketData::DeterministicSocketData(MockRead* reads, stopping_sequence_number_(0), stopped_(false), print_debug_(false) { + VerifyCorrectSequenceNumbers(reads, reads_count, writes, writes_count); } DeterministicSocketData::~DeterministicSocketData() {} @@ -603,6 +604,32 @@ void DeterministicSocketData::NextStep() { SetStopped(true); } +void DeterministicSocketData::VerifyCorrectSequenceNumbers( + MockRead* reads, size_t reads_count, + MockWrite* writes, size_t writes_count) { + size_t read = 0; + size_t write = 0; + int expected = 0; + while (read < reads_count || write < writes_count) { + // Check to see that we have a read or write at the expected + // state. + if (read < reads_count && reads[read].sequence_number == expected) { + ++read; + ++expected; + continue; + } + if (write < writes_count && writes[write].sequence_number == expected) { + ++write; + ++expected; + continue; + } + NOTREACHED() << "Missing sequence number: " << expected; + return; + } + DCHECK_EQ(read, reads_count); + DCHECK_EQ(write, writes_count); +} + MockClientSocketFactory::MockClientSocketFactory() {} MockClientSocketFactory::~MockClientSocketFactory() {} |