[Mac] Enable MacViews bookmark editor behind --enable-mac-views-dialogs.
[chromium-blink-merge.git] / net / cookies / parsed_cookie_unittest.cc
blob61a616777991d599d5a64abd2cbbfa28cfc69f77
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <string>
7 #include "net/cookies/cookie_constants.h"
8 #include "net/cookies/parsed_cookie.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace net {
13 TEST(ParsedCookieTest, TestBasic) {
14 ParsedCookie pc("a=b");
15 EXPECT_TRUE(pc.IsValid());
16 EXPECT_FALSE(pc.IsSecure());
17 EXPECT_EQ("a", pc.Name());
18 EXPECT_EQ("b", pc.Value());
21 TEST(ParsedCookieTest, TestEmpty) {
22 ParsedCookie pc1("=; path=/; secure;");
23 EXPECT_FALSE(pc1.IsValid());
24 ParsedCookie pc2("= ; path=/; secure;");
25 EXPECT_FALSE(pc2.IsValid());
26 ParsedCookie pc3(" =; path=/; secure;");
27 EXPECT_FALSE(pc3.IsValid());
28 ParsedCookie pc4(" = ; path=/; secure;");
29 EXPECT_FALSE(pc4.IsValid());
30 ParsedCookie pc5(" ; path=/; secure;");
31 EXPECT_FALSE(pc5.IsValid());
32 ParsedCookie pc6("; path=/; secure;");
33 EXPECT_FALSE(pc6.IsValid());
36 TEST(ParsedCookieTest, TestQuoted) {
37 // These are some quoting cases which the major browsers all
38 // handle differently. I've tested Internet Explorer 6, Opera 9.6,
39 // Firefox 3, and Safari Windows 3.2.1. We originally tried to match
40 // Firefox closely, however we now match Internet Explorer and Safari.
41 const char* const values[] = {
42 // Trailing whitespace after a quoted value. The whitespace after
43 // the quote is stripped in all browsers.
44 "\"zzz \" ",
45 "\"zzz \"",
46 // Handling a quoted value with a ';', like FOO="zz;pp" ;
47 // IE and Safari: "zz;
48 // Firefox and Opera: "zz;pp"
49 "\"zz;pp\" ;",
50 "\"zz",
51 // Handling a value with multiple quoted parts, like FOO="zzz " "ppp" ;
52 // IE and Safari: "zzz " "ppp";
53 // Firefox: "zzz ";
54 // Opera: <rejects cookie>
55 "\"zzz \" \"ppp\" ",
56 "\"zzz \" \"ppp\"",
57 // A quote in a value that didn't start quoted. like FOO=A"B ;
58 // IE, Safari, and Firefox: A"B;
59 // Opera: <rejects cookie>
60 "A\"B",
61 "A\"B",
64 for (size_t i = 0; i < arraysize(values); i += 2) {
65 std::string input(values[i]);
66 std::string expected(values[i + 1]);
68 ParsedCookie pc("aBc=" + input + " ; path=\"/\" ; httponly ");
69 EXPECT_TRUE(pc.IsValid());
70 EXPECT_FALSE(pc.IsSecure());
71 EXPECT_TRUE(pc.IsHttpOnly());
72 EXPECT_TRUE(pc.HasPath());
73 EXPECT_EQ("aBc", pc.Name());
74 EXPECT_EQ(expected, pc.Value());
76 // If a path was quoted, the path attribute keeps the quotes. This will
77 // make the cookie effectively useless, but path parameters aren't supposed
78 // to be quoted. Bug 1261605.
79 EXPECT_EQ("\"/\"", pc.Path());
83 TEST(ParsedCookieTest, TestNameless) {
84 ParsedCookie pc("BLAHHH; path=/; secure;");
85 EXPECT_TRUE(pc.IsValid());
86 EXPECT_TRUE(pc.IsSecure());
87 EXPECT_TRUE(pc.HasPath());
88 EXPECT_EQ("/", pc.Path());
89 EXPECT_EQ("", pc.Name());
90 EXPECT_EQ("BLAHHH", pc.Value());
91 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
94 TEST(ParsedCookieTest, TestAttributeCase) {
95 ParsedCookie pc(
96 "BLAHHH; Path=/; sECuRe; httpONLY; first-PaRty-only; pRIoRitY=hIgH");
97 EXPECT_TRUE(pc.IsValid());
98 EXPECT_TRUE(pc.IsSecure());
99 EXPECT_TRUE(pc.IsHttpOnly());
100 EXPECT_TRUE(pc.IsFirstPartyOnly());
101 EXPECT_TRUE(pc.HasPath());
102 EXPECT_EQ("/", pc.Path());
103 EXPECT_EQ("", pc.Name());
104 EXPECT_EQ("BLAHHH", pc.Value());
105 EXPECT_EQ(COOKIE_PRIORITY_HIGH, pc.Priority());
106 EXPECT_EQ(5U, pc.NumberOfAttributes());
109 TEST(ParsedCookieTest, TestDoubleQuotedNameless) {
110 ParsedCookie pc("\"BLA\\\"HHH\"; path=/; secure;");
111 EXPECT_TRUE(pc.IsValid());
112 EXPECT_TRUE(pc.IsSecure());
113 EXPECT_TRUE(pc.HasPath());
114 EXPECT_EQ("/", pc.Path());
115 EXPECT_EQ("", pc.Name());
116 EXPECT_EQ("\"BLA\\\"HHH\"", pc.Value());
117 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
118 EXPECT_EQ(2U, pc.NumberOfAttributes());
121 TEST(ParsedCookieTest, QuoteOffTheEnd) {
122 ParsedCookie pc("a=\"B");
123 EXPECT_TRUE(pc.IsValid());
124 EXPECT_EQ("a", pc.Name());
125 EXPECT_EQ("\"B", pc.Value());
126 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
127 EXPECT_EQ(0U, pc.NumberOfAttributes());
130 TEST(ParsedCookieTest, MissingName) {
131 ParsedCookie pc("=ABC");
132 EXPECT_TRUE(pc.IsValid());
133 EXPECT_EQ("", pc.Name());
134 EXPECT_EQ("ABC", pc.Value());
135 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
136 EXPECT_EQ(0U, pc.NumberOfAttributes());
139 TEST(ParsedCookieTest, MissingValue) {
140 ParsedCookie pc("ABC=; path = /wee");
141 EXPECT_TRUE(pc.IsValid());
142 EXPECT_EQ("ABC", pc.Name());
143 EXPECT_EQ("", pc.Value());
144 EXPECT_TRUE(pc.HasPath());
145 EXPECT_EQ("/wee", pc.Path());
146 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
147 EXPECT_EQ(1U, pc.NumberOfAttributes());
150 TEST(ParsedCookieTest, Whitespace) {
151 ParsedCookie pc(" A = BC ;secure;;; first-party-only ");
152 EXPECT_TRUE(pc.IsValid());
153 EXPECT_EQ("A", pc.Name());
154 EXPECT_EQ("BC", pc.Value());
155 EXPECT_FALSE(pc.HasPath());
156 EXPECT_FALSE(pc.HasDomain());
157 EXPECT_TRUE(pc.IsSecure());
158 EXPECT_FALSE(pc.IsHttpOnly());
159 EXPECT_TRUE(pc.IsFirstPartyOnly());
160 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
161 // We parse anything between ; as attributes, so we end up with two
162 // attributes with an empty string name and value.
163 EXPECT_EQ(4U, pc.NumberOfAttributes());
165 TEST(ParsedCookieTest, MultipleEquals) {
166 ParsedCookie pc(" A=== BC ;secure;;; httponly");
167 EXPECT_TRUE(pc.IsValid());
168 EXPECT_EQ("A", pc.Name());
169 EXPECT_EQ("== BC", pc.Value());
170 EXPECT_FALSE(pc.HasPath());
171 EXPECT_FALSE(pc.HasDomain());
172 EXPECT_TRUE(pc.IsSecure());
173 EXPECT_TRUE(pc.IsHttpOnly());
174 EXPECT_FALSE(pc.IsFirstPartyOnly());
175 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
176 EXPECT_EQ(4U, pc.NumberOfAttributes());
179 TEST(ParsedCookieTest, QuotedTrailingWhitespace) {
180 ParsedCookie pc(
181 "ANCUUID=\"zohNumRKgI0oxyhSsV3Z7D\" ; "
182 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; "
183 "path=/ ; ");
184 EXPECT_TRUE(pc.IsValid());
185 EXPECT_EQ("ANCUUID", pc.Name());
186 // Stripping whitespace after the quotes matches all other major browsers.
187 EXPECT_EQ("\"zohNumRKgI0oxyhSsV3Z7D\"", pc.Value());
188 EXPECT_TRUE(pc.HasExpires());
189 EXPECT_TRUE(pc.HasPath());
190 EXPECT_EQ("/", pc.Path());
191 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
192 EXPECT_EQ(2U, pc.NumberOfAttributes());
195 TEST(ParsedCookieTest, TrailingWhitespace) {
196 ParsedCookie pc(
197 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; "
198 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; "
199 "path=/ ; ");
200 EXPECT_TRUE(pc.IsValid());
201 EXPECT_EQ("ANCUUID", pc.Name());
202 EXPECT_EQ("zohNumRKgI0oxyhSsV3Z7D", pc.Value());
203 EXPECT_TRUE(pc.HasExpires());
204 EXPECT_TRUE(pc.HasPath());
205 EXPECT_EQ("/", pc.Path());
206 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
207 EXPECT_EQ(2U, pc.NumberOfAttributes());
210 TEST(ParsedCookieTest, TooManyPairs) {
211 std::string blankpairs;
212 blankpairs.resize(ParsedCookie::kMaxPairs - 2, ';');
214 ParsedCookie pc1("a=b;" + blankpairs + "secure");
215 EXPECT_TRUE(pc1.IsValid());
216 EXPECT_TRUE(pc1.IsSecure());
218 ParsedCookie pc2("a=b;" + blankpairs + ";secure");
219 EXPECT_TRUE(pc2.IsValid());
220 EXPECT_FALSE(pc2.IsSecure());
223 // TODO(erikwright): some better test cases for invalid cookies.
224 TEST(ParsedCookieTest, InvalidWhitespace) {
225 ParsedCookie pc(" ");
226 EXPECT_FALSE(pc.IsValid());
229 TEST(ParsedCookieTest, InvalidTooLong) {
230 std::string maxstr;
231 maxstr.resize(ParsedCookie::kMaxCookieSize, 'a');
233 ParsedCookie pc1(maxstr);
234 EXPECT_TRUE(pc1.IsValid());
236 ParsedCookie pc2(maxstr + "A");
237 EXPECT_FALSE(pc2.IsValid());
240 TEST(ParsedCookieTest, InvalidEmpty) {
241 ParsedCookie pc((std::string()));
242 EXPECT_FALSE(pc.IsValid());
245 TEST(ParsedCookieTest, EmbeddedTerminator) {
246 ParsedCookie pc1("AAA=BB\0ZYX");
247 ParsedCookie pc2("AAA=BB\rZYX");
248 ParsedCookie pc3("AAA=BB\nZYX");
249 EXPECT_TRUE(pc1.IsValid());
250 EXPECT_EQ("AAA", pc1.Name());
251 EXPECT_EQ("BB", pc1.Value());
252 EXPECT_TRUE(pc2.IsValid());
253 EXPECT_EQ("AAA", pc2.Name());
254 EXPECT_EQ("BB", pc2.Value());
255 EXPECT_TRUE(pc3.IsValid());
256 EXPECT_EQ("AAA", pc3.Name());
257 EXPECT_EQ("BB", pc3.Value());
260 TEST(ParsedCookieTest, ParseTokensAndValues) {
261 EXPECT_EQ("hello", ParsedCookie::ParseTokenString("hello\nworld"));
262 EXPECT_EQ("fs!!@", ParsedCookie::ParseTokenString("fs!!@;helloworld"));
263 EXPECT_EQ("hello world\tgood",
264 ParsedCookie::ParseTokenString("hello world\tgood\rbye"));
265 EXPECT_EQ("A", ParsedCookie::ParseTokenString("A=B=C;D=E"));
266 EXPECT_EQ("hello", ParsedCookie::ParseValueString("hello\nworld"));
267 EXPECT_EQ("fs!!@", ParsedCookie::ParseValueString("fs!!@;helloworld"));
268 EXPECT_EQ("hello world\tgood",
269 ParsedCookie::ParseValueString("hello world\tgood\rbye"));
270 EXPECT_EQ("A=B=C", ParsedCookie::ParseValueString("A=B=C;D=E"));
273 TEST(ParsedCookieTest, SerializeCookieLine) {
274 const char input[] =
275 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D ; "
276 "expires=Sun, 18-Apr-2027 21:06:29 GMT ; "
277 "path=/ ; priority=low ; ";
278 const char output[] =
279 "ANCUUID=zohNumRKgI0oxyhSsV3Z7D; "
280 "expires=Sun, 18-Apr-2027 21:06:29 GMT; "
281 "path=/; priority=low";
282 ParsedCookie pc(input);
283 EXPECT_EQ(output, pc.ToCookieLine());
286 TEST(ParsedCookieTest, SetNameAndValue) {
287 ParsedCookie empty((std::string()));
288 EXPECT_FALSE(empty.IsValid());
289 EXPECT_FALSE(empty.SetDomain("foobar.com"));
290 EXPECT_TRUE(empty.SetName("name"));
291 EXPECT_TRUE(empty.SetValue("value"));
292 EXPECT_EQ("name=value", empty.ToCookieLine());
293 EXPECT_TRUE(empty.IsValid());
295 // We don't test
296 // ParsedCookie invalid("@foo=bar");
297 // EXPECT_FALSE(invalid.IsValid());
298 // here because we are slightly more tolerant to invalid cookie names and
299 // values that are set by webservers. We only enforce a correct name and
300 // value if set via SetName() and SetValue().
302 ParsedCookie pc("name=value");
303 EXPECT_TRUE(pc.IsValid());
305 // Set invalid name / value.
306 EXPECT_FALSE(pc.SetName("@foobar"));
307 EXPECT_EQ("name=value", pc.ToCookieLine());
308 EXPECT_TRUE(pc.IsValid());
310 EXPECT_FALSE(pc.SetName(std::string()));
311 EXPECT_EQ("name=value", pc.ToCookieLine());
312 EXPECT_TRUE(pc.IsValid());
314 EXPECT_FALSE(pc.SetValue("foo bar"));
315 EXPECT_EQ("name=value", pc.ToCookieLine());
316 EXPECT_TRUE(pc.IsValid());
318 EXPECT_FALSE(pc.SetValue("\"foobar"));
319 EXPECT_EQ("name=value", pc.ToCookieLine());
320 EXPECT_TRUE(pc.IsValid());
322 // Set valid name / value
323 EXPECT_TRUE(pc.SetName("test"));
324 EXPECT_EQ("test=value", pc.ToCookieLine());
325 EXPECT_TRUE(pc.IsValid());
327 EXPECT_TRUE(pc.SetValue("\"foobar\""));
328 EXPECT_EQ("test=\"foobar\"", pc.ToCookieLine());
329 EXPECT_TRUE(pc.IsValid());
331 EXPECT_TRUE(pc.SetValue(std::string()));
332 EXPECT_EQ("test=", pc.ToCookieLine());
333 EXPECT_TRUE(pc.IsValid());
336 TEST(ParsedCookieTest, SetAttributes) {
337 ParsedCookie pc("name=value");
338 EXPECT_TRUE(pc.IsValid());
340 // Clear an unset attribute.
341 EXPECT_TRUE(pc.SetDomain(std::string()));
342 EXPECT_FALSE(pc.HasDomain());
343 EXPECT_EQ("name=value", pc.ToCookieLine());
344 EXPECT_TRUE(pc.IsValid());
346 // Set a string containing an invalid character
347 EXPECT_FALSE(pc.SetDomain("foo;bar"));
348 EXPECT_FALSE(pc.HasDomain());
349 EXPECT_EQ("name=value", pc.ToCookieLine());
350 EXPECT_TRUE(pc.IsValid());
352 // Set all other attributes and check that they are appended in order.
353 EXPECT_TRUE(pc.SetDomain("domain.com"));
354 EXPECT_TRUE(pc.SetPath("/"));
355 EXPECT_TRUE(pc.SetExpires("Sun, 18-Apr-2027 21:06:29 GMT"));
356 EXPECT_TRUE(pc.SetMaxAge("12345"));
357 EXPECT_TRUE(pc.SetIsSecure(true));
358 EXPECT_TRUE(pc.SetIsHttpOnly(true));
359 EXPECT_TRUE(pc.SetIsHttpOnly(true));
360 EXPECT_TRUE(pc.SetIsFirstPartyOnly(true));
361 EXPECT_TRUE(pc.SetPriority("HIGH"));
362 EXPECT_EQ(
363 "name=value; domain=domain.com; path=/; "
364 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; "
365 "httponly; first-party-only; priority=HIGH",
366 pc.ToCookieLine());
367 EXPECT_TRUE(pc.HasDomain());
368 EXPECT_TRUE(pc.HasPath());
369 EXPECT_TRUE(pc.HasExpires());
370 EXPECT_TRUE(pc.HasMaxAge());
371 EXPECT_TRUE(pc.IsSecure());
372 EXPECT_TRUE(pc.IsHttpOnly());
373 EXPECT_TRUE(pc.IsFirstPartyOnly());
374 EXPECT_EQ(COOKIE_PRIORITY_HIGH, pc.Priority());
376 // Clear one attribute from the middle.
377 EXPECT_TRUE(pc.SetPath("/foo"));
378 EXPECT_TRUE(pc.HasDomain());
379 EXPECT_TRUE(pc.HasPath());
380 EXPECT_TRUE(pc.HasExpires());
381 EXPECT_TRUE(pc.IsSecure());
382 EXPECT_TRUE(pc.IsHttpOnly());
383 EXPECT_EQ(
384 "name=value; domain=domain.com; path=/foo; "
385 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; "
386 "httponly; first-party-only; priority=HIGH",
387 pc.ToCookieLine());
389 // Set priority to medium.
390 EXPECT_TRUE(pc.SetPriority("medium"));
391 EXPECT_EQ(
392 "name=value; domain=domain.com; path=/foo; "
393 "expires=Sun, 18-Apr-2027 21:06:29 GMT; max-age=12345; secure; "
394 "httponly; first-party-only; priority=medium",
395 pc.ToCookieLine());
397 // Clear the rest and change the name and value.
398 EXPECT_TRUE(pc.SetDomain(std::string()));
399 EXPECT_TRUE(pc.SetPath(std::string()));
400 EXPECT_TRUE(pc.SetExpires(std::string()));
401 EXPECT_TRUE(pc.SetMaxAge(std::string()));
402 EXPECT_TRUE(pc.SetIsSecure(false));
403 EXPECT_TRUE(pc.SetIsHttpOnly(false));
404 EXPECT_TRUE(pc.SetIsFirstPartyOnly(false));
405 EXPECT_TRUE(pc.SetName("name2"));
406 EXPECT_TRUE(pc.SetValue("value2"));
407 EXPECT_TRUE(pc.SetPriority(std::string()));
408 EXPECT_FALSE(pc.HasDomain());
409 EXPECT_FALSE(pc.HasPath());
410 EXPECT_FALSE(pc.HasExpires());
411 EXPECT_FALSE(pc.HasMaxAge());
412 EXPECT_FALSE(pc.IsSecure());
413 EXPECT_FALSE(pc.IsHttpOnly());
414 EXPECT_FALSE(pc.IsFirstPartyOnly());
415 EXPECT_EQ("name2=value2", pc.ToCookieLine());
418 TEST(ParsedCookieTest, SetPriority) {
419 ParsedCookie pc("name=value");
420 EXPECT_TRUE(pc.IsValid());
422 EXPECT_EQ("name=value", pc.ToCookieLine());
423 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
425 // Test each priority, expect case-insensitive compare.
426 EXPECT_TRUE(pc.SetPriority("high"));
427 EXPECT_EQ("name=value; priority=high", pc.ToCookieLine());
428 EXPECT_EQ(COOKIE_PRIORITY_HIGH, pc.Priority());
430 EXPECT_TRUE(pc.SetPriority("mEDium"));
431 EXPECT_EQ("name=value; priority=mEDium", pc.ToCookieLine());
432 EXPECT_EQ(COOKIE_PRIORITY_MEDIUM, pc.Priority());
434 EXPECT_TRUE(pc.SetPriority("LOW"));
435 EXPECT_EQ("name=value; priority=LOW", pc.ToCookieLine());
436 EXPECT_EQ(COOKIE_PRIORITY_LOW, pc.Priority());
438 // Interpret invalid priority values as COOKIE_PRIORITY_DEFAULT.
439 EXPECT_TRUE(pc.SetPriority("Blah"));
440 EXPECT_EQ("name=value; priority=Blah", pc.ToCookieLine());
441 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
443 EXPECT_TRUE(pc.SetPriority("lowerest"));
444 EXPECT_EQ("name=value; priority=lowerest", pc.ToCookieLine());
445 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
447 EXPECT_TRUE(pc.SetPriority(""));
448 EXPECT_EQ("name=value", pc.ToCookieLine());
449 EXPECT_EQ(COOKIE_PRIORITY_DEFAULT, pc.Priority());
452 TEST(ParsedCookieTest, InvalidNonAlphanumericChars) {
453 ParsedCookie pc1("name=\x05");
454 ParsedCookie pc2(
455 "name=foo"
456 "\x1c"
457 "bar");
458 ParsedCookie pc3(
459 "name=foobar"
460 "\x11");
461 ParsedCookie pc4(
462 "name=\x02"
463 "foobar");
465 ParsedCookie pc5("\x05=value");
466 ParsedCookie pc6(
467 "foo"
468 "\x05"
469 "bar=value");
470 ParsedCookie pc7(
471 "foobar"
472 "\x05"
473 "=value");
474 ParsedCookie pc8(
475 "\x05"
476 "foobar"
477 "=value");
479 ParsedCookie pc9(
480 "foo"
481 "\x05"
482 "bar"
483 "=foo"
484 "\x05"
485 "bar");
487 ParsedCookie pc10(
488 "foo=bar;ba"
489 "\x05"
490 "z=boo");
491 ParsedCookie pc11(
492 "foo=bar;baz=bo"
493 "\x05"
494 "o");
495 ParsedCookie pc12(
496 "foo=bar;ba"
497 "\05"
498 "z=bo"
499 "\x05"
500 "o");
502 EXPECT_FALSE(pc1.IsValid());
503 EXPECT_FALSE(pc2.IsValid());
504 EXPECT_FALSE(pc3.IsValid());
505 EXPECT_FALSE(pc4.IsValid());
506 EXPECT_FALSE(pc5.IsValid());
507 EXPECT_FALSE(pc6.IsValid());
508 EXPECT_FALSE(pc7.IsValid());
509 EXPECT_FALSE(pc8.IsValid());
510 EXPECT_FALSE(pc9.IsValid());
511 EXPECT_FALSE(pc10.IsValid());
512 EXPECT_FALSE(pc11.IsValid());
513 EXPECT_FALSE(pc12.IsValid());
516 TEST(ParsedCookieTest, ValidNonAlphanumericChars) {
517 // Note that some of these words are pasted backwords thanks to poor vim bidi
518 // support. This should not affect the tests, however.
519 const char pc1_literal[] = "name=العربية";
520 const char pc2_literal[] = "name=普通話";
521 const char pc3_literal[] = "name=ภาษาไทย";
522 const char pc4_literal[] = "name=עִבְרִית";
523 const char pc5_literal[] = "العربية=value";
524 const char pc6_literal[] = "普通話=value";
525 const char pc7_literal[] = "ภาษาไทย=value";
526 const char pc8_literal[] = "עִבְרִית=value";
527 ParsedCookie pc1(pc1_literal);
528 ParsedCookie pc2(pc2_literal);
529 ParsedCookie pc3(pc3_literal);
530 ParsedCookie pc4(pc4_literal);
531 ParsedCookie pc5(pc5_literal);
532 ParsedCookie pc6(pc6_literal);
533 ParsedCookie pc7(pc7_literal);
534 ParsedCookie pc8(pc8_literal);
536 EXPECT_TRUE(pc1.IsValid());
537 EXPECT_EQ(pc1_literal, pc1.ToCookieLine());
538 EXPECT_TRUE(pc2.IsValid());
539 EXPECT_EQ(pc2_literal, pc2.ToCookieLine());
540 EXPECT_TRUE(pc3.IsValid());
541 EXPECT_EQ(pc3_literal, pc3.ToCookieLine());
542 EXPECT_TRUE(pc4.IsValid());
543 EXPECT_EQ(pc4_literal, pc4.ToCookieLine());
544 EXPECT_TRUE(pc5.IsValid());
545 EXPECT_EQ(pc5_literal, pc5.ToCookieLine());
546 EXPECT_TRUE(pc6.IsValid());
547 EXPECT_EQ(pc6_literal, pc6.ToCookieLine());
548 EXPECT_TRUE(pc7.IsValid());
549 EXPECT_EQ(pc7_literal, pc7.ToCookieLine());
550 EXPECT_TRUE(pc8.IsValid());
551 EXPECT_EQ(pc8_literal, pc8.ToCookieLine());