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

Side by Side Diff: net/socket/socket_test_util.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 EXPECT_EQ(expected_data, actual_data); 226 EXPECT_EQ(expected_data, actual_data);
227 return expected_data == actual_data; 227 return expected_data == actual_data;
228 } 228 }
229 229
230 const MockWrite& StaticSocketDataHelper::PeekRealWrite() const { 230 const MockWrite& StaticSocketDataHelper::PeekRealWrite() const {
231 for (size_t i = write_index_; i < write_count_; i++) { 231 for (size_t i = write_index_; i < write_count_; i++) {
232 if (writes_[i].mode != ASYNC || writes_[i].result != ERR_IO_PENDING) 232 if (writes_[i].mode != ASYNC || writes_[i].result != ERR_IO_PENDING)
233 return writes_[i]; 233 return writes_[i];
234 } 234 }
235 235
236 CHECK(false) << "No write data available."; 236 // No write data available.
237 CHECK(false);
237 return writes_[0]; // Avoid warning about unreachable missing return. 238 return writes_[0]; // Avoid warning about unreachable missing return.
238 } 239 }
239 240
240 StaticSocketDataProvider::StaticSocketDataProvider() 241 StaticSocketDataProvider::StaticSocketDataProvider()
241 : StaticSocketDataProvider(nullptr, 0, nullptr, 0) { 242 : StaticSocketDataProvider(nullptr, 0, nullptr, 0) {
242 } 243 }
243 244
244 StaticSocketDataProvider::StaticSocketDataProvider(MockRead* reads, 245 StaticSocketDataProvider::StaticSocketDataProvider(MockRead* reads,
245 size_t reads_count, 246 size_t reads_count,
246 MockWrite* writes, 247 MockWrite* writes,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 size_t next_read = 0; 331 size_t next_read = 0;
331 size_t next_write = 0; 332 size_t next_write = 0;
332 int next_sequence_number = 0; 333 int next_sequence_number = 0;
333 bool last_event_was_pause = false; 334 bool last_event_was_pause = false;
334 while (next_read < reads_count || next_write < writes_count) { 335 while (next_read < reads_count || next_write < writes_count) {
335 if (next_read < reads_count && 336 if (next_read < reads_count &&
336 reads[next_read].sequence_number == next_sequence_number) { 337 reads[next_read].sequence_number == next_sequence_number) {
337 // Check if this is a pause. 338 // Check if this is a pause.
338 if (reads[next_read].mode == ASYNC && 339 if (reads[next_read].mode == ASYNC &&
339 reads[next_read].result == ERR_IO_PENDING) { 340 reads[next_read].result == ERR_IO_PENDING) {
340 CHECK(!last_event_was_pause) << "Two pauses in a row are not allowed: " 341 // Two pauses in a row are not allowed.
341 << next_sequence_number; 342 CHECK(!last_event_was_pause);
342 last_event_was_pause = true; 343 last_event_was_pause = true;
343 } else if (last_event_was_pause) { 344 } else if (last_event_was_pause) {
344 CHECK_EQ(ASYNC, reads[next_read].mode) 345 // A sync event after a pause makes no sense.
345 << "A sync event after a pause makes no sense: " 346 CHECK_EQ(ASYNC, reads[next_read].mode);
346 << next_sequence_number; 347 // A pause event after a pause makes no sense.
347 CHECK_NE(ERR_IO_PENDING, reads[next_read].result) 348 CHECK_NE(ERR_IO_PENDING, reads[next_read].result);
348 << "A pause event after a pause makes no sense: "
349 << next_sequence_number;
350 last_event_was_pause = false; 349 last_event_was_pause = false;
351 } 350 }
352 351
353 ++next_read; 352 ++next_read;
354 ++next_sequence_number; 353 ++next_sequence_number;
355 continue; 354 continue;
356 } 355 }
357 if (next_write < writes_count && 356 if (next_write < writes_count &&
358 writes[next_write].sequence_number == next_sequence_number) { 357 writes[next_write].sequence_number == next_sequence_number) {
359 // Check if this is a pause. 358 // Check if this is a pause.
360 if (writes[next_write].mode == ASYNC && 359 if (writes[next_write].mode == ASYNC &&
361 writes[next_write].result == ERR_IO_PENDING) { 360 writes[next_write].result == ERR_IO_PENDING) {
362 CHECK(!last_event_was_pause) << "Two pauses in a row are not allowed: " 361 // Two pauses in a row are not allowed.
363 << next_sequence_number; 362 CHECK(!last_event_was_pause);
364 last_event_was_pause = true; 363 last_event_was_pause = true;
365 } else if (last_event_was_pause) { 364 } else if (last_event_was_pause) {
366 CHECK_EQ(ASYNC, writes[next_write].mode) 365 // A sync event after a pause makes no sense.
367 << "A sync event after a pause makes no sense: " 366 CHECK_EQ(ASYNC, writes[next_write].mode);
368 << next_sequence_number; 367 // A pause event after a pause makes no sense.
369 CHECK_NE(ERR_IO_PENDING, writes[next_write].result) 368 CHECK_NE(ERR_IO_PENDING, writes[next_write].result);
370 << "A pause event after a pause makes no sense: "
371 << next_sequence_number;
372 last_event_was_pause = false; 369 last_event_was_pause = false;
373 } 370 }
374 371
375 ++next_write; 372 ++next_write;
376 ++next_sequence_number; 373 ++next_sequence_number;
377 continue; 374 continue;
378 } 375 }
379 CHECK(false) << "Sequence number not found where expected: " 376 // Sequence number not found where expected.
380 << next_sequence_number; 377 CHECK(false);
381 return; 378 return;
382 } 379 }
383 380
384 // Last event must not be a pause. For the final event to indicate the 381 // Last event must not be a pause. For the final event to indicate the
385 // operation never completes, it should be SYNCHRONOUS and return 382 // operation never completes, it should be SYNCHRONOUS and return
386 // ERR_IO_PENDING. 383 // ERR_IO_PENDING.
387 CHECK(!last_event_was_pause); 384 CHECK(!last_event_was_pause);
388 385
389 CHECK_EQ(next_read, reads_count); 386 CHECK_EQ(next_read, reads_count);
390 CHECK_EQ(next_write, writes_count); 387 CHECK_EQ(next_write, writes_count);
(...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 } 1741 }
1745 1742
1746 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) { 1743 int64_t CountWriteBytes(const MockWrite writes[], size_t writes_size) {
1747 int64_t total = 0; 1744 int64_t total = 0;
1748 for (const MockWrite* write = writes; write != writes + writes_size; ++write) 1745 for (const MockWrite* write = writes; write != writes + writes_size; ++write)
1749 total += write->data_len; 1746 total += write->data_len;
1750 return total; 1747 return total;
1751 } 1748 }
1752 1749
1753 } // namespace net 1750 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698