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

Side by Side Diff: third_party/WebKit/Source/wtf/testing/WTFTestPrinters.cpp

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "wtf/text/AtomicString.h" 31 #include "wtf/text/AtomicString.h"
32 #include "wtf/text/WTFString.h" 32 #include "wtf/text/WTFString.h"
33 #include <ostream> // NOLINT 33 #include <ostream> // NOLINT
34 34
35 namespace WTF { 35 namespace WTF {
36 36
37 std::ostream& operator<<(std::ostream& out, const String& string) 37 std::ostream& operator<<(std::ostream& out, const String& string) {
38 { 38 if (string.isNull())
39 if (string.isNull()) 39 return out << "<null>";
40 return out << "<null>";
41 40
42 out << '"'; 41 out << '"';
43 for (unsigned index = 0; index < string.length(); ++index) { 42 for (unsigned index = 0; index < string.length(); ++index) {
44 // Print shorthands for select cases. 43 // Print shorthands for select cases.
45 UChar character = string[index]; 44 UChar character = string[index];
46 switch (character) { 45 switch (character) {
47 case '\t': 46 case '\t':
48 out << "\\t"; 47 out << "\\t";
49 break; 48 break;
50 case '\n': 49 case '\n':
51 out << "\\n"; 50 out << "\\n";
52 break; 51 break;
53 case '\r': 52 case '\r':
54 out << "\\r"; 53 out << "\\r";
55 break; 54 break;
56 case '"': 55 case '"':
57 out << "\\\""; 56 out << "\\\"";
58 break; 57 break;
59 case '\\': 58 case '\\':
60 out << "\\\\"; 59 out << "\\\\";
61 break; 60 break;
62 default: 61 default:
63 if (character >= 0x20 && character < 0x7F) { 62 if (character >= 0x20 && character < 0x7F) {
64 out << static_cast<char>(character); 63 out << static_cast<char>(character);
65 } else { 64 } else {
66 // Print "\uXXXX" for control or non-ASCII characters. 65 // Print "\uXXXX" for control or non-ASCII characters.
67 out << "\\u"; 66 out << "\\u";
68 out.width(4); 67 out.width(4);
69 out.fill('0'); 68 out.fill('0');
70 out.setf(std::ios_base::hex, std::ios_base::basefield); 69 out.setf(std::ios_base::hex, std::ios_base::basefield);
71 out.setf(std::ios::uppercase); 70 out.setf(std::ios::uppercase);
72 out << character; 71 out << character;
73 }
74 break;
75 } 72 }
73 break;
76 } 74 }
77 return out << '"'; 75 }
76 return out << '"';
78 } 77 }
79 78
80 std::ostream& operator<<(std::ostream& out, const AtomicString& s) 79 std::ostream& operator<<(std::ostream& out, const AtomicString& s) {
81 { 80 return out << s.string();
82 return out << s.string();
83 } 81 }
84 82
85 } // namespace WTF 83 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/testing/RunAllTests.cpp ('k') | third_party/WebKit/Source/wtf/testing/WTFTestPrintersTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698