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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringOperatorsTest.cpp

Issue 2771783003: Move wtf_unittests to platform/wtf/. (Closed)
Patch Set: Rebase. Created 3 years, 8 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
(Empty)
1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #define WTF_STRINGTYPEADAPTER_COPIED_WTF_STRING() (++wtfStringCopyCount)
27
28 static int wtfStringCopyCount;
29
30 #include "testing/gtest/include/gtest/gtest.h"
31 #include "wtf/text/WTFString.h"
32
33 namespace WTF {
34
35 #define EXPECT_N_WTF_STRING_COPIES(count, expr) \
36 do { \
37 wtfStringCopyCount = 0; \
38 String __testString = expr; \
39 (void)__testString; \
40 EXPECT_EQ(count, wtfStringCopyCount) << #expr; \
41 } while (false)
42
43 TEST(StringOperatorsTest, DISABLED_StringOperators) {
44 String string("String");
45 AtomicString atomicString("AtomicString");
46 const char* literal = "ASCIILiteral";
47
48 EXPECT_EQ(0, wtfStringCopyCount);
49
50 EXPECT_N_WTF_STRING_COPIES(2, string + string);
51 EXPECT_N_WTF_STRING_COPIES(2, string + atomicString);
52 EXPECT_N_WTF_STRING_COPIES(2, atomicString + string);
53 EXPECT_N_WTF_STRING_COPIES(2, atomicString + atomicString);
54
55 EXPECT_N_WTF_STRING_COPIES(1, "C string" + string);
56 EXPECT_N_WTF_STRING_COPIES(1, string + "C string");
57 EXPECT_N_WTF_STRING_COPIES(1, "C string" + atomicString);
58 EXPECT_N_WTF_STRING_COPIES(1, atomicString + "C string");
59
60 EXPECT_N_WTF_STRING_COPIES(1, literal + string);
61 EXPECT_N_WTF_STRING_COPIES(1, string + literal);
62 EXPECT_N_WTF_STRING_COPIES(1, literal + atomicString);
63 EXPECT_N_WTF_STRING_COPIES(1, atomicString + literal);
64
65 EXPECT_N_WTF_STRING_COPIES(2, "C string" + string + "C string" + string);
66 EXPECT_N_WTF_STRING_COPIES(2, "C string" + (string + "C string" + string));
67 EXPECT_N_WTF_STRING_COPIES(2, ("C string" + string) + ("C string" + string));
68 EXPECT_N_WTF_STRING_COPIES(2, string + "C string" + string + "C string");
69 EXPECT_N_WTF_STRING_COPIES(2, string + ("C string" + string + "C string"));
70 EXPECT_N_WTF_STRING_COPIES(2, (string + "C string") + (string + "C string"));
71
72 EXPECT_N_WTF_STRING_COPIES(2, literal + string + literal + string);
73 EXPECT_N_WTF_STRING_COPIES(2, literal + (string + literal + string));
74 EXPECT_N_WTF_STRING_COPIES(2, (literal + string) + (literal + string));
75 EXPECT_N_WTF_STRING_COPIES(2, string + literal + string + literal);
76 EXPECT_N_WTF_STRING_COPIES(2, string + (literal + string + literal));
77 EXPECT_N_WTF_STRING_COPIES(2, (string + literal) + (string + literal));
78
79 EXPECT_N_WTF_STRING_COPIES(2, literal + string + "C string" + string);
80 EXPECT_N_WTF_STRING_COPIES(2, literal + (string + "C string" + string));
81 EXPECT_N_WTF_STRING_COPIES(2, (literal + string) + ("C string" + string));
82 EXPECT_N_WTF_STRING_COPIES(2, "C string" + string + literal + string);
83 EXPECT_N_WTF_STRING_COPIES(2, "C string" + (string + literal + string));
84 EXPECT_N_WTF_STRING_COPIES(2, ("C string" + string) + (literal + string));
85
86 EXPECT_N_WTF_STRING_COPIES(
87 2, literal + atomicString + "C string" + atomicString);
88 EXPECT_N_WTF_STRING_COPIES(
89 2, literal + (atomicString + "C string" + atomicString));
90 EXPECT_N_WTF_STRING_COPIES(
91 2, (literal + atomicString) + ("C string" + atomicString));
92 EXPECT_N_WTF_STRING_COPIES(
93 2, "C string" + atomicString + literal + atomicString);
94 EXPECT_N_WTF_STRING_COPIES(
95 2, "C string" + (atomicString + literal + atomicString));
96 EXPECT_N_WTF_STRING_COPIES(
97 2, ("C string" + atomicString) + (literal + atomicString));
98
99 EXPECT_N_WTF_STRING_COPIES(2, literal + atomicString + "C string" + string);
100 EXPECT_N_WTF_STRING_COPIES(2, literal + (atomicString + "C string" + string));
101 EXPECT_N_WTF_STRING_COPIES(2,
102 (literal + atomicString) + ("C string" + string));
103 EXPECT_N_WTF_STRING_COPIES(2, "C string" + atomicString + literal + string);
104 EXPECT_N_WTF_STRING_COPIES(2, "C string" + (atomicString + literal + string));
105 EXPECT_N_WTF_STRING_COPIES(2,
106 ("C string" + atomicString) + (literal + string));
107
108 EXPECT_N_WTF_STRING_COPIES(2, literal + string + "C string" + atomicString);
109 EXPECT_N_WTF_STRING_COPIES(2, literal + (string + "C string" + atomicString));
110 EXPECT_N_WTF_STRING_COPIES(2,
111 (literal + string) + ("C string" + atomicString));
112 EXPECT_N_WTF_STRING_COPIES(2, "C string" + string + literal + atomicString);
113 EXPECT_N_WTF_STRING_COPIES(2, "C string" + (string + literal + atomicString));
114 EXPECT_N_WTF_STRING_COPIES(2,
115 ("C string" + string) + (literal + atomicString));
116
117 EXPECT_N_WTF_STRING_COPIES(
118 2, "C string" + atomicString + "C string" + atomicString);
119 EXPECT_N_WTF_STRING_COPIES(
120 2, "C string" + (atomicString + "C string" + atomicString));
121 EXPECT_N_WTF_STRING_COPIES(
122 2, ("C string" + atomicString) + ("C string" + atomicString));
123 EXPECT_N_WTF_STRING_COPIES(
124 2, atomicString + "C string" + atomicString + "C string");
125 EXPECT_N_WTF_STRING_COPIES(
126 2, atomicString + ("C string" + atomicString + "C string"));
127 EXPECT_N_WTF_STRING_COPIES(
128 2, (atomicString + "C string") + (atomicString + "C string"));
129
130 EXPECT_N_WTF_STRING_COPIES(2,
131 literal + atomicString + literal + atomicString);
132 EXPECT_N_WTF_STRING_COPIES(2,
133 literal + (atomicString + literal + atomicString));
134 EXPECT_N_WTF_STRING_COPIES(
135 2, (literal + atomicString) + (literal + atomicString));
136 EXPECT_N_WTF_STRING_COPIES(2,
137 atomicString + literal + atomicString + literal);
138 EXPECT_N_WTF_STRING_COPIES(2,
139 atomicString + (literal + atomicString + literal));
140 EXPECT_N_WTF_STRING_COPIES(
141 2, (atomicString + literal) + (atomicString + literal));
142
143 EXPECT_N_WTF_STRING_COPIES(2,
144 "C string" + string + "C string" + atomicString);
145 EXPECT_N_WTF_STRING_COPIES(2,
146 "C string" + (string + "C string" + atomicString));
147 EXPECT_N_WTF_STRING_COPIES(
148 2, ("C string" + string) + ("C string" + atomicString));
149 EXPECT_N_WTF_STRING_COPIES(2,
150 string + "C string" + atomicString + "C string");
151 EXPECT_N_WTF_STRING_COPIES(2,
152 string + ("C string" + atomicString + "C string"));
153 EXPECT_N_WTF_STRING_COPIES(
154 2, (string + "C string") + (atomicString + "C string"));
155
156 EXPECT_N_WTF_STRING_COPIES(2, literal + string + literal + atomicString);
157 EXPECT_N_WTF_STRING_COPIES(2, literal + (string + literal + atomicString));
158 EXPECT_N_WTF_STRING_COPIES(2, (literal + string) + (literal + atomicString));
159 EXPECT_N_WTF_STRING_COPIES(2, string + literal + atomicString + literal);
160 EXPECT_N_WTF_STRING_COPIES(2, string + (literal + atomicString + literal));
161 EXPECT_N_WTF_STRING_COPIES(2, (string + literal) + (atomicString + literal));
162
163 EXPECT_N_WTF_STRING_COPIES(2,
164 "C string" + atomicString + "C string" + string);
165 EXPECT_N_WTF_STRING_COPIES(2,
166 "C string" + (atomicString + "C string" + string));
167 EXPECT_N_WTF_STRING_COPIES(
168 2, ("C string" + atomicString) + ("C string" + string));
169 EXPECT_N_WTF_STRING_COPIES(2,
170 atomicString + "C string" + string + "C string");
171 EXPECT_N_WTF_STRING_COPIES(2,
172 atomicString + ("C string" + string + "C string"));
173 EXPECT_N_WTF_STRING_COPIES(
174 2, (atomicString + "C string") + (string + "C string"));
175
176 EXPECT_N_WTF_STRING_COPIES(2, literal + atomicString + literal + string);
177 EXPECT_N_WTF_STRING_COPIES(2, literal + (atomicString + literal + string));
178 EXPECT_N_WTF_STRING_COPIES(2, (literal + atomicString) + (literal + string));
179 EXPECT_N_WTF_STRING_COPIES(2, atomicString + literal + string + literal);
180 EXPECT_N_WTF_STRING_COPIES(2, atomicString + (literal + string + literal));
181 EXPECT_N_WTF_STRING_COPIES(2, (atomicString + literal) + (string + literal));
182
183 #if COMPILER(MSVC)
184 EXPECT_N_WTF_STRING_COPIES(1, L"wide string" + string);
185 EXPECT_N_WTF_STRING_COPIES(1, string + L"wide string");
186 EXPECT_N_WTF_STRING_COPIES(1, L"wide string" + atomicString);
187 EXPECT_N_WTF_STRING_COPIES(1, atomicString + L"wide string");
188
189 EXPECT_N_WTF_STRING_COPIES(2,
190 L"wide string" + string + L"wide string" + string);
191 EXPECT_N_WTF_STRING_COPIES(
192 2, L"wide string" + (string + L"wide string" + string));
193 EXPECT_N_WTF_STRING_COPIES(
194 2, (L"wide string" + string) + (L"wide string" + string));
195 EXPECT_N_WTF_STRING_COPIES(2,
196 string + L"wide string" + string + L"wide string");
197 EXPECT_N_WTF_STRING_COPIES(
198 2, string + (L"wide string" + string + L"wide string"));
199 EXPECT_N_WTF_STRING_COPIES(
200 2, (string + L"wide string") + (string + L"wide string"));
201
202 EXPECT_N_WTF_STRING_COPIES(
203 2, L"wide string" + atomicString + L"wide string" + atomicString);
204 EXPECT_N_WTF_STRING_COPIES(
205 2, L"wide string" + (atomicString + L"wide string" + atomicString));
206 EXPECT_N_WTF_STRING_COPIES(
207 2, (L"wide string" + atomicString) + (L"wide string" + atomicString));
208 EXPECT_N_WTF_STRING_COPIES(
209 2, atomicString + L"wide string" + atomicString + L"wide string");
210 EXPECT_N_WTF_STRING_COPIES(
211 2, atomicString + (L"wide string" + atomicString + L"wide string"));
212 EXPECT_N_WTF_STRING_COPIES(
213 2, (atomicString + L"wide string") + (atomicString + L"wide string"));
214
215 EXPECT_N_WTF_STRING_COPIES(
216 2, L"wide string" + string + L"wide string" + atomicString);
217 EXPECT_N_WTF_STRING_COPIES(
218 2, L"wide string" + (string + L"wide string" + atomicString));
219 EXPECT_N_WTF_STRING_COPIES(
220 2, (L"wide string" + string) + (L"wide string" + atomicString));
221 EXPECT_N_WTF_STRING_COPIES(
222 2, string + L"wide string" + atomicString + L"wide string");
223 EXPECT_N_WTF_STRING_COPIES(
224 2, string + (L"wide string" + atomicString + L"wide string"));
225 EXPECT_N_WTF_STRING_COPIES(
226 2, (string + L"wide string") + (atomicString + L"wide string"));
227
228 EXPECT_N_WTF_STRING_COPIES(
229 2, L"wide string" + atomicString + L"wide string" + string);
230 EXPECT_N_WTF_STRING_COPIES(
231 2, L"wide string" + (atomicString + L"wide string" + string));
232 EXPECT_N_WTF_STRING_COPIES(
233 2, (L"wide string" + atomicString) + (L"wide string" + string));
234 EXPECT_N_WTF_STRING_COPIES(
235 2, atomicString + L"wide string" + string + L"wide string");
236 EXPECT_N_WTF_STRING_COPIES(
237 2, atomicString + (L"wide string" + string + L"wide string"));
238 EXPECT_N_WTF_STRING_COPIES(
239 2, (atomicString + L"wide string") + (string + L"wide string"));
240 #endif
241 }
242
243 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImplTest.cpp ('k') | third_party/WebKit/Source/wtf/text/StringToNumberTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698