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

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

Issue 9296005: Delete net::GetHeaderParamValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja")); 625 HttpUtil::GenerateAcceptLanguageHeader("en-US,fr,de,ko,zh-CN,ja"));
626 } 626 }
627 627
628 TEST(HttpUtilTest, GenerateAcceptCharsetHeader) { 628 TEST(HttpUtilTest, GenerateAcceptCharsetHeader) {
629 EXPECT_EQ(std::string("utf-8,*;q=0.5"), 629 EXPECT_EQ(std::string("utf-8,*;q=0.5"),
630 HttpUtil::GenerateAcceptCharsetHeader("utf-8")); 630 HttpUtil::GenerateAcceptCharsetHeader("utf-8"));
631 EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"), 631 EXPECT_EQ(std::string("EUC-JP,utf-8;q=0.7,*;q=0.3"),
632 HttpUtil::GenerateAcceptCharsetHeader("EUC-JP")); 632 HttpUtil::GenerateAcceptCharsetHeader("EUC-JP"));
633 } 633 }
634 634
635 TEST(HttpUtilTest, ParseContentType) {
636 const struct {
637 const char* content_type;
638 const char* expected_mime_type;
639 const char* expected_charset;
640 const bool expected_had_charset;
641 const char* expected_boundary;
642 } tests[] = {
643 { "text/html; boundary=\"WebKit-ada-df-dsf-adsfadsfs\"",
644 "text/html",
645 "",
646 false,
647 "\"WebKit-ada-df-dsf-adsfadsfs\""
648 }
649 // TODO(abarth): Add more interesting test cases.
650 };
651 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
652 std::string mime_type;
653 std::string charset;
654 bool had_charset;
655 std::string boundary;
656 net::HttpUtil::ParseContentType(tests[i].content_type, &mime_type,
657 &charset, &had_charset, &boundary);
658 EXPECT_EQ(tests[i].expected_mime_type, mime_type) << "i=" << i;
659 EXPECT_EQ(tests[i].expected_charset, charset) << "i=" << i;
660 EXPECT_EQ(tests[i].expected_had_charset, had_charset) << "i=" << i;
661 EXPECT_EQ(tests[i].expected_boundary, boundary) << "i=" << i;
662 }
663 }
664
635 TEST(HttpUtilTest, ParseRanges) { 665 TEST(HttpUtilTest, ParseRanges) {
636 const struct { 666 const struct {
637 const char* headers; 667 const char* headers;
638 bool expected_return_value; 668 bool expected_return_value;
639 size_t expected_ranges_size; 669 size_t expected_ranges_size;
640 const struct { 670 const struct {
641 int64 expected_first_byte_position; 671 int64 expected_first_byte_position;
642 int64 expected_last_byte_position; 672 int64 expected_last_byte_position;
643 int64 expected_suffix_length; 673 int64 expected_suffix_length;
644 } expected_ranges[10]; 674 } expected_ranges[10];
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) { 987 TEST(HttpUtilTest, NameValuePairsIteratorMissingEndQuote) {
958 std::string data = "name='value"; 988 std::string data = "name='value";
959 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';'); 989 HttpUtil::NameValuePairsIterator parser(data.begin(), data.end(), ';');
960 EXPECT_TRUE(parser.valid()); 990 EXPECT_TRUE(parser.valid());
961 991
962 ASSERT_NO_FATAL_FAILURE( 992 ASSERT_NO_FATAL_FAILURE(
963 CheckNextNameValuePair(&parser, true, true, "name", "value")); 993 CheckNextNameValuePair(&parser, true, true, "name", "value"));
964 ASSERT_NO_FATAL_FAILURE( 994 ASSERT_NO_FATAL_FAILURE(
965 CheckNextNameValuePair(&parser, false, true, "", "")); 995 CheckNextNameValuePair(&parser, false, true, "", ""));
966 } 996 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698