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 #if !LOG_DISABLED | |
12 namespace WTF { | 11 namespace WTF { |
13 | 12 |
| 13 TEST(AssertionsTest, Assertions) { |
| 14 ASSERT(true); |
| 15 #if ENABLE(ASSERT) |
| 16 EXPECT_DEATH_IF_SUPPORTED(ASSERT(false), ""); |
| 17 EXPECT_DEATH_IF_SUPPORTED(ASSERT_NOT_REACHED(), ""); |
| 18 #endif |
| 19 |
| 20 RELEASE_ASSERT(true); |
| 21 EXPECT_DEATH_IF_SUPPORTED(RELEASE_ASSERT(false), ""); |
| 22 |
| 23 SECURITY_DCHECK(true); |
| 24 #if ENABLE(SECURITY_ASSERT) |
| 25 EXPECT_DEATH_IF_SUPPORTED(SECURITY_DCHECK(false), ""); |
| 26 #endif |
| 27 |
| 28 SECURITY_CHECK(true); |
| 29 EXPECT_DEATH_IF_SUPPORTED(SECURITY_CHECK(false), ""); |
| 30 |
| 31 EXPECT_DEATH_IF_SUPPORTED(CRASH(), ""); |
| 32 EXPECT_DEATH_IF_SUPPORTED(IMMEDIATE_CRASH(), ""); |
| 33 }; |
| 34 |
| 35 #if !LOG_DISABLED |
14 static const int kPrinterBufferSize = 256; | 36 static const int kPrinterBufferSize = 256; |
15 static char gBuffer[kPrinterBufferSize]; | 37 static char gBuffer[kPrinterBufferSize]; |
16 static StringBuilder gBuilder; | 38 static StringBuilder gBuilder; |
17 | 39 |
18 static void vprint(const char* format, va_list args) { | 40 static void vprint(const char* format, va_list args) { |
19 int written = vsnprintf(gBuffer, kPrinterBufferSize, format, args); | 41 int written = vsnprintf(gBuffer, kPrinterBufferSize, format, args); |
20 if (written > 0 && written < kPrinterBufferSize) | 42 if (written > 0 && written < kPrinterBufferSize) |
21 gBuilder.append(gBuffer); | 43 gBuilder.append(gBuffer); |
22 } | 44 } |
23 | 45 |
(...skipping 14 matching lines...) Expand all Loading... |
38 | 60 |
39 EXPECT_EQ( | 61 EXPECT_EQ( |
40 "( a1\n" | 62 "( a1\n" |
41 " ( c\n" | 63 " ( c\n" |
42 " ( d -1 hello )\n" | 64 " ( d -1 hello )\n" |
43 " )\n" | 65 " )\n" |
44 " a2 0.5\n" | 66 " a2 0.5\n" |
45 ")\n", | 67 ")\n", |
46 gBuilder.toString()); | 68 gBuilder.toString()); |
47 }; | 69 }; |
| 70 #endif // !LOG_DISABLED |
48 | 71 |
49 } // namespace WTF | 72 } // namespace WTF |
50 #endif // !LOG_DISABLED | |
OLD | NEW |