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

Unified Diff: net/socket/socket_test_util.cc

Issue 582020: Add bounds checking to StaticSocketDataProvider, to make tests more reliable (Closed)
Patch Set: Created 10 years, 10 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/socket/socks5_client_socket_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 283ae352b2abccb2d6089cf61e3d5f676be07280..1ea1ec96fc22ed73a6f2d7e570ad7c2671df1444 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -284,11 +284,8 @@ int MockSSLClientSocket::Write(net::IOBuffer* buf, int buf_len,
}
MockRead StaticSocketDataProvider::GetNextRead() {
- MockRead rv = reads_[read_index_];
- if (reads_[read_index_].result != OK ||
- reads_[read_index_].data_len != 0)
- read_index_++; // Don't advance past an EOF.
- return rv;
+ DCHECK(!at_read_eof());
+ return reads_[read_index_++];
}
MockWriteResult StaticSocketDataProvider::OnWrite(const std::string& data) {
@@ -297,6 +294,8 @@ MockWriteResult StaticSocketDataProvider::OnWrite(const std::string& data) {
return MockWriteResult(false, data.length());
}
+ DCHECK(!at_write_eof());
+
// Check that what we are writing matches the expectation.
// Then give the mocked return value.
net::MockWrite* w = &writes_[write_index_++];
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/socks5_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698