Chromium Code Reviews| Index: net/http/http_util_unittest.cc |
| =================================================================== |
| --- net/http/http_util_unittest.cc (revision 100022) |
| +++ net/http/http_util_unittest.cc (working copy) |
| @@ -195,7 +195,7 @@ |
| TEST(HttpUtilTest, AssembleRawHeaders) { |
| struct { |
| - const char* input; |
| + const char* input; // with '|' representing \0 |
|
wtc
2011/09/12 18:48:09
Nit: \0 => '\0'
eroman
2011/09/12 21:19:24
Done.
|
| const char* expected_result; // with '\0' changed to '|' |
| } tests[] = { |
| { "HTTP/1.0 200 OK\r\nFoo: 1\r\nBar: 2\r\n\r\n", |
| @@ -482,12 +482,26 @@ |
| "Bar: 2||", |
| }, |
| + // Embed NULLs in the status line. They should not be understood |
| + // as line separators. |
| + { |
| + "HTTP/1.0 200 OK|Bar2:0|Baz2:1\r\nFoo: 1\r\nBar: 2\r\n\r\n", |
| + "HTTP/1.0 200 OKBar2:0Baz2:1|Foo: 1|Bar: 2||" |
| + }, |
| + |
| + // Embed NULLs in a header line. They should not be understood as |
| + // line separators. |
| + { |
| + "HTTP/1.0 200 OK\nFoo: 1|Foo2: 3\nBar: 2\n\n", |
| + "HTTP/1.0 200 OK|Foo: 1Foo2: 3|Bar: 2||" |
| + }, |
| }; |
| for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { |
| - int input_len = static_cast<int>(strlen(tests[i].input)); |
| - std::string raw = HttpUtil::AssembleRawHeaders(tests[i].input, input_len); |
| + std::string input = tests[i].input; |
| + std::replace(input.begin(), input.end(), '|', '\0'); |
| + std::string raw = HttpUtil::AssembleRawHeaders(input.data(), input.size()); |
| std::replace(raw.begin(), raw.end(), '\0', '|'); |
| - EXPECT_TRUE(raw == tests[i].expected_result); |
| + EXPECT_EQ(raw, tests[i].expected_result); |
|
wtc
2011/09/12 18:48:09
Nit: reverse the arguments of EXPECT_EQ? I think
eroman
2011/09/12 21:19:24
Done.
|
| } |
| } |