| 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 "platform/wtf/Assertions.h" | 5 #include "platform/wtf/Assertions.h" |
| 6 | 6 |
| 7 #include "platform/wtf/text/StringBuilder.h" | 7 #include "platform/wtf/text/StringBuilder.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.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 DCHECK(true); | 14 DCHECK(true); |
| 15 #if DCHECK_IS_ON() | 15 #if DCHECK_IS_ON() |
| 16 EXPECT_DEATH_IF_SUPPORTED(DCHECK(false), ""); | 16 EXPECT_DEATH_IF_SUPPORTED(DCHECK(false), ""); |
| 17 EXPECT_DEATH_IF_SUPPORTED(NOTREACHED(), ""); | 17 EXPECT_DEATH_IF_SUPPORTED(NOTREACHED(), ""); |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 CHECK(true); | 20 CHECK(true); |
| 21 EXPECT_DEATH_IF_SUPPORTED(CHECK(false), ""); | 21 EXPECT_DEATH_IF_SUPPORTED(CHECK(false), ""); |
| 22 | 22 |
| 23 SECURITY_DCHECK(true); | 23 SECURITY_DCHECK(true); |
| 24 #if ENABLE(SECURITY_ASSERT) | 24 #if ENABLE(SECURITY_ASSERT) |
| 25 EXPECT_DEATH_IF_SUPPORTED(SECURITY_DCHECK(false), ""); | 25 EXPECT_DEATH_IF_SUPPORTED(SECURITY_DCHECK(false), ""); |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 SECURITY_CHECK(true); | 28 SECURITY_CHECK(true); |
| 29 EXPECT_DEATH_IF_SUPPORTED(SECURITY_CHECK(false), ""); | 29 EXPECT_DEATH_IF_SUPPORTED(SECURITY_CHECK(false), ""); |
| 30 | |
| 31 EXPECT_DEATH_IF_SUPPORTED(IMMEDIATE_CRASH(), ""); | |
| 32 EXPECT_DEATH_IF_SUPPORTED(IMMEDIATE_CRASH(), ""); | |
| 33 }; | 30 }; |
| 34 | 31 |
| 35 #if !LOG_DISABLED | 32 #if !LOG_DISABLED |
| 36 static const int kPrinterBufferSize = 256; | 33 static const int kPrinterBufferSize = 256; |
| 37 static char g_buffer[kPrinterBufferSize]; | 34 static char g_buffer[kPrinterBufferSize]; |
| 38 static StringBuilder g_builder; | 35 static StringBuilder g_builder; |
| 39 | 36 |
| 40 static void Vprint(const char* format, va_list args) { | 37 static void Vprint(const char* format, va_list args) { |
| 41 int written = vsnprintf(g_buffer, kPrinterBufferSize, format, args); | 38 int written = vsnprintf(g_buffer, kPrinterBufferSize, format, args); |
| 42 if (written > 0 && written < kPrinterBufferSize) | 39 if (written > 0 && written < kPrinterBufferSize) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 " ( c\n" | 60 " ( c\n" |
| 64 " ( d -1 hello )\n" | 61 " ( d -1 hello )\n" |
| 65 " )\n" | 62 " )\n" |
| 66 " a2 0.5\n" | 63 " a2 0.5\n" |
| 67 ")\n", | 64 ")\n", |
| 68 g_builder.ToString()); | 65 g_builder.ToString()); |
| 69 }; | 66 }; |
| 70 #endif // !LOG_DISABLED | 67 #endif // !LOG_DISABLED |
| 71 | 68 |
| 72 } // namespace WTF | 69 } // namespace WTF |
| OLD | NEW |