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

Side by Side Diff: net/http/http_util_unittest.cc

Issue 17340: Add q-values to languages in Accept-Language HTTP header to be compatible wit... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« net/http/http_util.h ('K') | « net/http/http_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "net/http/http_util.h" 8 #include "net/http/http_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 "HTTP/1.0 404|" 320 "HTTP/1.0 404|"
321 " Not Found|" 321 " Not Found|"
322 "Foo: 1|" 322 "Foo: 1|"
323 "Bar: 2||" 323 "Bar: 2||"
324 }, 324 },
325 325
326 // Unterminated status line. 326 // Unterminated status line.
327 { 327 {
328 "HTTP/1.0 200 OK", 328 "HTTP/1.0 200 OK",
329 329
330 "HTTP/1.0 200 OK||" 330 "HTTP/1.0 200 OK||"
331 }, 331 },
332 332
333 // Single terminated, with headers 333 // Single terminated, with headers
334 { 334 {
335 "HTTP/1.0 200 OK\n" 335 "HTTP/1.0 200 OK\n"
336 "Foo: 1\n" 336 "Foo: 1\n"
337 "Bar: 2\n", 337 "Bar: 2\n",
338 338
339 "HTTP/1.0 200 OK|" 339 "HTTP/1.0 200 OK|"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 }; 468 };
469 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 469 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
470 GURL url(GURL(tests[i].url)); 470 GURL url(GURL(tests[i].url));
471 std::string expected_spec(tests[i].expected_spec); 471 std::string expected_spec(tests[i].expected_spec);
472 std::string expected_path(tests[i].expected_path); 472 std::string expected_path(tests[i].expected_path);
473 473
474 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url)); 474 EXPECT_EQ(expected_spec, HttpUtil::SpecForRequest(url));
475 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url)); 475 EXPECT_EQ(expected_path, HttpUtil::PathForRequest(url));
476 } 476 }
477 } 477 }
478
479 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) {
480 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"),
481 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de"));
482 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2,"
483 "ja;q=0.2"),
484 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja"));
485 }
486
487 TEST(HttpUtilTest, GenerateAcceptCharsetHeader) {
488 EXPECT_EQ(std::string("utf-8,*;q=0.5"),
489 HttpUtil::GenerateAcceptCharsetHeader("utf-8"));
490 EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"),
491 HttpUtil::GenerateAcceptCharsetHeader("EUC-JP"));
492 }
493
OLDNEW
« net/http/http_util.h ('K') | « net/http/http_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698