OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdlib.h> | 5 #include <stdlib.h> |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "mojo/public/cpp/environment/environment.h" | 10 #include "mojo/public/cpp/environment/environment.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 MOJO_DCHECK(true) << "hello"; | 444 MOJO_DCHECK(true) << "hello"; |
445 EXPECT_FALSE(log_message_was_called()); | 445 EXPECT_FALSE(log_message_was_called()); |
446 | 446 |
447 ResetMockLogger(); | 447 ResetMockLogger(); |
448 | 448 |
449 // |MOJO_DCHECK()| should compile (but not evaluate) its condition even for | 449 // |MOJO_DCHECK()| should compile (but not evaluate) its condition even for |
450 // non-debug builds. (Hopefully, we'll get an unused variable error if it | 450 // non-debug builds. (Hopefully, we'll get an unused variable error if it |
451 // fails to compile the condition.) | 451 // fails to compile the condition.) |
452 bool was_called = false; | 452 bool was_called = false; |
453 MOJO_DCHECK(DcheckTestHelper(&was_called)) << "hello"; | 453 MOJO_DCHECK(DcheckTestHelper(&was_called)) << "hello"; |
454 #ifdef NDEBUG | 454 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
455 EXPECT_FALSE(was_called); | 455 EXPECT_FALSE(was_called); |
456 EXPECT_FALSE(log_message_was_called()); | 456 EXPECT_FALSE(log_message_was_called()); |
457 #else | 457 #else |
458 EXPECT_TRUE(was_called); | 458 EXPECT_TRUE(was_called); |
459 EXPECT_TRUE(log_message_was_called()); | 459 EXPECT_TRUE(log_message_was_called()); |
460 EXPECT_EQ(MOJO_LOG_LEVEL_FATAL, last_log_level()); | 460 EXPECT_EQ(MOJO_LOG_LEVEL_FATAL, last_log_level()); |
461 // Different compilers have different ideas about the line number of a split | 461 // Different compilers have different ideas about the line number of a split |
462 // line. | 462 // line. |
463 int line = __LINE__; | 463 int line = __LINE__; |
464 EXPECT_EQ( | 464 EXPECT_EQ( |
465 ExpectedLogMessage(line - 10, | 465 ExpectedLogMessage(line - 10, |
466 "Check failed: DcheckTestHelper(&was_called). hello"), | 466 "Check failed: DcheckTestHelper(&was_called). hello"), |
467 last_message()); | 467 last_message()); |
468 #endif | 468 #endif |
469 | 469 |
470 ResetMockLogger(); | 470 ResetMockLogger(); |
471 | 471 |
472 // Also try to make sure that we parenthesize the condition properly. | 472 // Also try to make sure that we parenthesize the condition properly. |
473 bool x = true; | 473 bool x = true; |
474 MOJO_DCHECK(false || x) << "hello"; | 474 MOJO_DCHECK(false || x) << "hello"; |
475 EXPECT_FALSE(log_message_was_called()); | 475 EXPECT_FALSE(log_message_was_called()); |
476 } | 476 } |
477 | 477 |
478 } // namespace | 478 } // namespace |
479 } // namespace mojo | 479 } // namespace mojo |
OLD | NEW |