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

Unified Diff: net/http/http_util_unittest.cc

Issue 2608563002: Remove some dead code for operating on headers-as-a-string. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« net/http/http_util.h ('K') | « net/http/http_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_util_unittest.cc
diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc
index ee38dc6a465019d14df5be0753b3e4c0e0fd7ea0..d0829d504e71cef547af5bdc2dff18a345379fb4 100644
--- a/net/http/http_util_unittest.cc
+++ b/net/http/http_util_unittest.cc
@@ -120,29 +120,6 @@ TEST(HttpUtilTest, HasHeader) {
}
}
-TEST(HttpUtilTest, StripHeaders) {
- static const char* const headers =
- "Origin: origin\r\n"
- "Content-Type: text/plain\r\n"
- "Cookies: foo1\r\n"
- "Custom: baz\r\n"
- "COOKIES: foo2\r\n"
- "Server: Apache\r\n"
- "OrIGin: origin2\r\n";
-
- static const char* const header_names[] = {
- "origin", "content-type", "cookies"
- };
-
- static const char* const expected_stripped_headers =
- "Custom: baz\r\n"
- "Server: Apache\r\n";
-
- EXPECT_EQ(expected_stripped_headers,
- HttpUtil::StripHeaders(headers, header_names,
- arraysize(header_names)));
-}
-
TEST(HttpUtilTest, HeadersIterator) {
std::string headers = "foo: 1\t\r\nbar: hello world\r\nbaz: 3 \r\n";
@@ -844,139 +821,6 @@ TEST(HttpUtilTest, ParseContentType) {
}
}
-TEST(HttpUtilTest, ParseRanges) {
- const struct {
- const char* const headers;
- bool expected_return_value;
- size_t expected_ranges_size;
- const struct {
- int64_t expected_first_byte_position;
- int64_t expected_last_byte_position;
- int64_t expected_suffix_length;
- } expected_ranges[10];
- } tests[] = {
- { "Range: bytes=0-10",
- true,
- 1,
- { {0, 10, -1}, }
- },
- { "Range: bytes=10-0",
- false,
- 0,
- {}
- },
- { "Range: BytES=0-10",
- true,
- 1,
- { {0, 10, -1}, }
- },
- { "Range: megabytes=0-10",
- false,
- 0,
- {}
- },
- { "Range: bytes0-10",
- false,
- 0,
- {}
- },
- { "Range: bytes=0-0,0-10,10-20,100-200,100-,-200",
- true,
- 6,
- { {0, 0, -1},
- {0, 10, -1},
- {10, 20, -1},
- {100, 200, -1},
- {100, -1, -1},
- {-1, -1, 200},
- }
- },
- { "Range: bytes=0-10\r\n"
- "Range: bytes=0-10,10-20,100-200,100-,-200",
- true,
- 1,
- { {0, 10, -1}
- }
- },
- { "Range: bytes=",
- false,
- 0,
- {}
- },
- { "Range: bytes=-",
- false,
- 0,
- {}
- },
- { "Range: bytes=0-10-",
- false,
- 0,
- {}
- },
- { "Range: bytes=-0-10",
- false,
- 0,
- {}
- },
- { "Range: bytes =0-10\r\n",
- true,
- 1,
- { {0, 10, -1}
- }
- },
- { "Range: bytes= 0-10 \r\n",
- true,
- 1,
- { {0, 10, -1}
- }
- },
- { "Range: bytes = 0 - 10 \r\n",
- true,
- 1,
- { {0, 10, -1}
- }
- },
- { "Range: bytes= 0-1 0\r\n",
- false,
- 0,
- {}
- },
- { "Range: bytes= 0- -10\r\n",
- false,
- 0,
- {}
- },
- { "Range: bytes= 0 - 1 , 10 -20, 100- 200 , 100-, -200 \r\n",
- true,
- 5,
- { {0, 1, -1},
- {10, 20, -1},
- {100, 200, -1},
- {100, -1, -1},
- {-1, -1, 200},
- }
- },
- };
-
- for (size_t i = 0; i < arraysize(tests); ++i) {
- std::vector<HttpByteRange> ranges;
- bool return_value = HttpUtil::ParseRanges(std::string(tests[i].headers),
- &ranges);
- EXPECT_EQ(tests[i].expected_return_value, return_value);
- if (return_value) {
- EXPECT_EQ(tests[i].expected_ranges_size, ranges.size());
- for (size_t j = 0; j < ranges.size(); ++j) {
- EXPECT_EQ(tests[i].expected_ranges[j].expected_first_byte_position,
- ranges[j].first_byte_position());
- EXPECT_EQ(tests[i].expected_ranges[j].expected_last_byte_position,
- ranges[j].last_byte_position());
- EXPECT_EQ(tests[i].expected_ranges[j].expected_suffix_length,
- ranges[j].suffix_length());
- }
- }
- }
-}
-
TEST(HttpUtilTest, ParseContentRangeHeader) {
const struct {
const char* const content_range_header_spec;
« 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