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

Side by Side Diff: third_party/WebKit/Source/wtf/AssertionsTest.cpp

Issue 1436153002: Apply clang-format with Chromium-style without column limit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « third_party/WebKit/Source/wtf/Assertions.cpp ('k') | third_party/WebKit/Source/wtf/Atomics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #define ENABLE_ASSERT 1 5 #define ENABLE_ASSERT 1
6 6
7 #include "config.h" 7 #include "config.h"
8 #include "wtf/Assertions.h" 8 #include "wtf/Assertions.h"
9 9
10 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
11 11
12 #include <gtest/gtest.h> 12 #include <gtest/gtest.h>
13 #include <stdio.h> 13 #include <stdio.h>
14 14
15 namespace WTF { 15 namespace WTF {
16 16
17 static const int kPrinterBufferSize = 256; 17 static const int kPrinterBufferSize = 256;
18 static char gBuffer[kPrinterBufferSize]; 18 static char gBuffer[kPrinterBufferSize];
19 static StringBuilder gBuilder; 19 static StringBuilder gBuilder;
20 20
21 static void vprint(const char* format, va_list args) 21 static void vprint(const char* format, va_list args) {
22 { 22 int written = vsnprintf(gBuffer, kPrinterBufferSize, format, args);
23 int written = vsnprintf(gBuffer, kPrinterBufferSize, format, args); 23 if (written > 0 && written < kPrinterBufferSize)
24 if (written > 0 && written < kPrinterBufferSize) 24 gBuilder.append(gBuffer);
25 gBuilder.append(gBuffer);
26 } 25 }
27 26
28 class AssertionsTest : public testing::Test { 27 class AssertionsTest : public testing::Test {
29 protected: 28 protected:
30 AssertionsTest() 29 AssertionsTest() {
31 { 30 ScopedLogger::setPrintFuncForTests(vprint);
32 ScopedLogger::setPrintFuncForTests(vprint); 31 }
33 }
34 }; 32 };
35 33
36 TEST_F(AssertionsTest, ScopedLogger) 34 TEST_F(AssertionsTest, ScopedLogger) {
37 { 35 {
36 WTF_CREATE_SCOPED_LOGGER(a, "a1");
38 { 37 {
39 WTF_CREATE_SCOPED_LOGGER(a, "a1"); 38 WTF_CREATE_SCOPED_LOGGER_IF(b, false, "b1");
39 {
40 WTF_CREATE_SCOPED_LOGGER(c, "c");
40 { 41 {
41 WTF_CREATE_SCOPED_LOGGER_IF(b, false, "b1"); 42 WTF_CREATE_SCOPED_LOGGER(d, "d %d %s", -1, "hello");
42 {
43 WTF_CREATE_SCOPED_LOGGER(c, "c");
44 {
45 WTF_CREATE_SCOPED_LOGGER(d, "d %d %s", -1, "hello");
46 }
47 }
48 WTF_APPEND_SCOPED_LOGGER(b, "b2");
49 } 43 }
50 WTF_APPEND_SCOPED_LOGGER(a, "a2 %.1f", 0.5); 44 }
45 WTF_APPEND_SCOPED_LOGGER(b, "b2");
51 } 46 }
47 WTF_APPEND_SCOPED_LOGGER(a, "a2 %.1f", 0.5);
48 }
52 49
53 EXPECT_EQ( 50 EXPECT_EQ(
54 "( a1\n" 51 "( a1\n"
55 " ( c\n" 52 " ( c\n"
56 " ( d -1 hello )\n" 53 " ( d -1 hello )\n"
57 " )\n" 54 " )\n"
58 " a2 0.5\n" 55 " a2 0.5\n"
59 ")\n", gBuilder.toString()); 56 ")\n",
57 gBuilder.toString());
60 }; 58 };
61 59
62 60 } // namespace WTF
63 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/Assertions.cpp ('k') | third_party/WebKit/Source/wtf/Atomics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698