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

Side by Side Diff: third_party/WebKit/Source/core/testing/UnionTypesTest.cpp

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bad assert. Created 4 years, 6 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/testing/UnionTypesTest.h" 5 #include "core/testing/UnionTypesTest.h"
6 6
7 #include "wtf/text/StringBuilder.h" 7 #include "wtf/text/StringBuilder.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 String UnionTypesTest::doubleOrStringArrayArg(HeapVector<DoubleOrString>& array) 70 String UnionTypesTest::doubleOrStringArrayArg(HeapVector<DoubleOrString>& array)
71 { 71 {
72 if (!array.size()) 72 if (!array.size())
73 return ""; 73 return "";
74 74
75 StringBuilder builder; 75 StringBuilder builder;
76 for (DoubleOrString& doubleOrString : array) { 76 for (DoubleOrString& doubleOrString : array) {
77 ASSERT(!doubleOrString.isNull()); 77 ASSERT(!doubleOrString.isNull());
78 if (doubleOrString.isDouble()) 78 if (doubleOrString.isDouble()) {
79 builder.append("double: " + String::numberToStringECMAScript(doubleO rString.getAsDouble())); 79 builder.append("double: ");
80 else if (doubleOrString.isString()) 80 builder.append(String::numberToStringECMAScript(doubleOrString.getAs Double()));
81 builder.append("string: " + doubleOrString.getAsString()); 81 } else if (doubleOrString.isString()) {
82 else 82 builder.append("string: ");
83 builder.append(doubleOrString.getAsString());
84 } else {
83 ASSERT_NOT_REACHED(); 85 ASSERT_NOT_REACHED();
86 }
84 builder.append(", "); 87 builder.append(", ");
85 } 88 }
86 return builder.substring(0, builder.length() - 2); 89 return builder.substring(0, builder.length() - 2);
87 } 90 }
88 91
89 String UnionTypesTest::doubleOrStringSequenceArg(HeapVector<DoubleOrString>& seq uence) 92 String UnionTypesTest::doubleOrStringSequenceArg(HeapVector<DoubleOrString>& seq uence)
90 { 93 {
91 return doubleOrStringArrayArg(sequence); 94 return doubleOrStringArrayArg(sequence);
92 } 95 }
93 96
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 builder.append("sequence: ["); 156 builder.append("sequence: [");
154 for (const String& item : sequence) { 157 for (const String& item : sequence) {
155 ASSERT(!item.isNull()); 158 ASSERT(!item.isNull());
156 builder.append(item); 159 builder.append(item);
157 builder.append(", "); 160 builder.append(", ");
158 } 161 }
159 return builder.substring(0, builder.length() - 2) + "]"; 162 return builder.substring(0, builder.length() - 2) + "]";
160 } 163 }
161 164
162 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698