OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "wtf/Assertions.h" | 5 #include "wtf/Assertions.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "wtf/text/StringBuilder.h" | 8 #include "wtf/text/StringBuilder.h" |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 | 10 |
11 namespace WTF { | 11 namespace WTF { |
12 | 12 |
13 TEST(AssertionsTest, Assertions) { | 13 TEST(AssertionsTest, Assertions) { |
14 ASSERT(true); | 14 ASSERT(true); |
15 #if DCHECK_IS_ON() | 15 #if DCHECK_IS_ON() && !defined(DCHECK_IS_DUMP_WITHOUT_CRASH) |
16 EXPECT_DEATH_IF_SUPPORTED(ASSERT(false), ""); | 16 EXPECT_DEATH_IF_SUPPORTED(ASSERT(false), ""); |
17 EXPECT_DEATH_IF_SUPPORTED(ASSERT_NOT_REACHED(), ""); | 17 EXPECT_DEATH_IF_SUPPORTED(ASSERT_NOT_REACHED(), ""); |
| 18 EXPECT_DEATH_IF_SUPPORTED(DCHECK_AT(false, __FILE__, __LINE__), ""); |
| 19 #else |
| 20 ASSERT(false); |
| 21 ASSERT_NOT_REACHED(); |
| 22 DCHECK_AT(false, __FILE__, __LINE__); |
18 #endif | 23 #endif |
19 | 24 |
20 RELEASE_ASSERT(true); | 25 RELEASE_ASSERT(true); |
21 EXPECT_DEATH_IF_SUPPORTED(RELEASE_ASSERT(false), ""); | 26 EXPECT_DEATH_IF_SUPPORTED(RELEASE_ASSERT(false), ""); |
22 | 27 |
23 SECURITY_DCHECK(true); | 28 SECURITY_DCHECK(true); |
24 #if ENABLE(SECURITY_ASSERT) | 29 #if ENABLE(SECURITY_ASSERT) |
25 EXPECT_DEATH_IF_SUPPORTED(SECURITY_DCHECK(false), ""); | 30 EXPECT_DEATH_IF_SUPPORTED(SECURITY_DCHECK(false), ""); |
| 31 #else |
| 32 SECURITY_DCHECK(false); |
26 #endif | 33 #endif |
27 | 34 |
28 SECURITY_CHECK(true); | 35 SECURITY_CHECK(true); |
29 EXPECT_DEATH_IF_SUPPORTED(SECURITY_CHECK(false), ""); | 36 EXPECT_DEATH_IF_SUPPORTED(SECURITY_CHECK(false), ""); |
30 | 37 |
31 EXPECT_DEATH_IF_SUPPORTED(CRASH(), ""); | 38 EXPECT_DEATH_IF_SUPPORTED(CRASH(), ""); |
32 EXPECT_DEATH_IF_SUPPORTED(IMMEDIATE_CRASH(), ""); | 39 EXPECT_DEATH_IF_SUPPORTED(IMMEDIATE_CRASH(), ""); |
33 }; | 40 }; |
34 | 41 |
35 #if !LOG_DISABLED | 42 #if !LOG_DISABLED |
(...skipping 27 matching lines...) Expand all Loading... |
63 " ( c\n" | 70 " ( c\n" |
64 " ( d -1 hello )\n" | 71 " ( d -1 hello )\n" |
65 " )\n" | 72 " )\n" |
66 " a2 0.5\n" | 73 " a2 0.5\n" |
67 ")\n", | 74 ")\n", |
68 gBuilder.toString()); | 75 gBuilder.toString()); |
69 }; | 76 }; |
70 #endif // !LOG_DISABLED | 77 #endif // !LOG_DISABLED |
71 | 78 |
72 } // namespace WTF | 79 } // namespace WTF |
OLD | NEW |