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

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

Issue 12463021: Stop sending Accept-Charset HTTP header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r188089) Created 7 years, 9 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
« no previous file with comments | « net/http/http_util.cc ('k') | net/url_request/http_user_agent_settings.h » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 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 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 "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/http/http_util.h" 9 #include "net/http/http_util.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 626
627 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) { 627 TEST(HttpUtilTest, GenerateAcceptLanguageHeader) {
628 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"), 628 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6"),
629 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de")); 629 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de"));
630 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2," 630 EXPECT_EQ(std::string("en-US,fr;q=0.8,de;q=0.6,ko;q=0.4,zh-CN;q=0.2,"
631 "ja;q=0.2"), 631 "ja;q=0.2"),
632 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja")); 632 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja"));
633 } 633 }
634 634
635 TEST(HttpUtilTest, GenerateAcceptCharsetHeader) {
636 EXPECT_EQ(std::string("utf-8,*;q=0.5"),
637 HttpUtil::GenerateAcceptCharsetHeader("utf-8"));
638 EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"),
639 HttpUtil::GenerateAcceptCharsetHeader("EUC-JP"));
640 }
641
642 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType. 635 // HttpResponseHeadersTest.GetMimeType also tests ParseContentType.
643 TEST(HttpUtilTest, ParseContentType) { 636 TEST(HttpUtilTest, ParseContentType) {
644 const struct { 637 const struct {
645 const char* content_type; 638 const char* content_type;
646 const char* expected_mime_type; 639 const char* expected_mime_type;
647 const char* expected_charset; 640 const char* expected_charset;
648 const bool expected_had_charset; 641 const bool expected_had_charset;
649 const char* expected_boundary; 642 const char* expected_boundary;
650 } tests[] = { 643 } tests[] = {
651 { "text/html; charset=utf-8", 644 { "text/html; charset=utf-8",
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { 1042 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) {
1050 std::string data = "name='value"; 1043 std::string data = "name='value";
1051 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); 1044 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';');
1052 EXPECT_TRUE(parser.valid()); 1045 EXPECT_TRUE(parser.valid());
1053 1046
1054 ASSERT_NO_FATAL_FAILURE( 1047 ASSERT_NO_FATAL_FAILURE(
1055 CheckNextNameValuePair(&parser, true, true, "name", "value")); 1048 CheckNextNameValuePair(&parser, true, true, "name", "value"));
1056 ASSERT_NO_FATAL_FAILURE( 1049 ASSERT_NO_FATAL_FAILURE(
1057 CheckNextNameValuePair(&parser, false, true, "", "")); 1050 CheckNextNameValuePair(&parser, false, true, "", ""));
1058 } 1051 }
OLDNEW
« no previous file with comments | « net/http/http_util.cc ('k') | net/url_request/http_user_agent_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698