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

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

Issue 662553002: Convert ARRAYSIZE_UNSAFE -> arraysize in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_transaction_unittest.cc » ('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 "net/http/http_content_disposition.h" 5 #include "net/http/http_content_disposition.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace net { 10 namespace net {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 // attfnboth 188 // attfnboth
189 {"attachment; filename=\"foo-ae.html\"; " 189 {"attachment; filename=\"foo-ae.html\"; "
190 "filename*=UTF-8''foo-%c3%a4.html", "", L"foo-\xe4.html"}, 190 "filename*=UTF-8''foo-%c3%a4.html", "", L"foo-\xe4.html"},
191 // attfnboth2 191 // attfnboth2
192 {"attachment; filename*=UTF-8''foo-%c3%a4.html; " 192 {"attachment; filename*=UTF-8''foo-%c3%a4.html; "
193 "filename=\"foo-ae.html\"", "", L"foo-\xe4.html"}, 193 "filename=\"foo-ae.html\"", "", L"foo-\xe4.html"},
194 // attnewandfn 194 // attnewandfn
195 {"attachment; foobar=x; filename=\"foo.html\"", "", 195 {"attachment; foobar=x; filename=\"foo.html\"", "",
196 L"foo.html"}, 196 L"foo.html"},
197 }; 197 };
198 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 198 for (size_t i = 0; i < arraysize(tests); ++i) {
199 HttpContentDisposition header(tests[i].header, tests[i].referrer_charset); 199 HttpContentDisposition header(tests[i].header, tests[i].referrer_charset);
200 EXPECT_EQ(tests[i].expected, 200 EXPECT_EQ(tests[i].expected,
201 base::UTF8ToWide(header.filename())) 201 base::UTF8ToWide(header.filename()))
202 << "Failed on input: " << tests[i].header; 202 << "Failed on input: " << tests[i].header;
203 } 203 }
204 } 204 }
205 205
206 // Test cases from http://greenbytes.de/tech/tc2231/ 206 // Test cases from http://greenbytes.de/tech/tc2231/
207 TEST(HttpContentDispositionTest, tc2231) { 207 TEST(HttpContentDispositionTest, tc2231) {
208 const struct FileNameCDCase { 208 const struct FileNameCDCase {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 // http://greenbytes.de/tech/tc2231/#attnewandfn 496 // http://greenbytes.de/tech/tc2231/#attnewandfn
497 { "attachment; foobar=x; filename=\"foo.html\"", 497 { "attachment; foobar=x; filename=\"foo.html\"",
498 net::HttpContentDisposition::ATTACHMENT, 498 net::HttpContentDisposition::ATTACHMENT,
499 L"foo.html" 499 L"foo.html"
500 }, 500 },
501 // TODO(abarth): Add the filename* tests, but check 501 // TODO(abarth): Add the filename* tests, but check
502 // HttpContentDispositionTest.Filename for overlap. 502 // HttpContentDispositionTest.Filename for overlap.
503 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047token 503 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047token
504 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047quoted 504 // TODO(abarth): http://greenbytes.de/tech/tc2231/#attrfc2047quoted
505 }; 505 };
506 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) { 506 for (size_t i = 0; i < arraysize(tests); ++i) {
507 HttpContentDisposition header(tests[i].header, std::string()); 507 HttpContentDisposition header(tests[i].header, std::string());
508 EXPECT_EQ(tests[i].expected_type, header.type()) 508 EXPECT_EQ(tests[i].expected_type, header.type())
509 << "Failed on input: " << tests[i].header; 509 << "Failed on input: " << tests[i].header;
510 EXPECT_EQ(tests[i].expected_filename, base::UTF8ToWide(header.filename())) 510 EXPECT_EQ(tests[i].expected_filename, base::UTF8ToWide(header.filename()))
511 << "Failed on input: " << tests[i].header; 511 << "Failed on input: " << tests[i].header;
512 } 512 }
513 } 513 }
514 514
515 TEST(HttpContentDispositionTest, ParseResult) { 515 TEST(HttpContentDispositionTest, ParseResult) {
516 const struct ParseResultTestCase { 516 const struct ParseResultTestCase {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS | 569 HttpContentDisposition::HAS_PERCENT_ENCODED_STRINGS |
570 HttpContentDisposition::HAS_RFC2047_ENCODED_STRINGS }, 570 HttpContentDisposition::HAS_RFC2047_ENCODED_STRINGS },
571 571
572 // If 'filename' attribute is invalid, should set any flags based on it. 572 // If 'filename' attribute is invalid, should set any flags based on it.
573 { "filename=foo\xcc\x88 foo%cc%88 =?utf-8?Q?foo?", 573 { "filename=foo\xcc\x88 foo%cc%88 =?utf-8?Q?foo?",
574 HttpContentDisposition::INVALID }, 574 HttpContentDisposition::INVALID },
575 { "filename=foo\xcc\x88 foo%cc%88 =?utf-8?Q?foo?; name=x", 575 { "filename=foo\xcc\x88 foo%cc%88 =?utf-8?Q?foo?; name=x",
576 HttpContentDisposition::HAS_NAME }, 576 HttpContentDisposition::HAS_NAME },
577 }; 577 };
578 578
579 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { 579 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
580 const ParseResultTestCase& test_case = kTestCases[i]; 580 const ParseResultTestCase& test_case = kTestCases[i];
581 HttpContentDisposition content_disposition(test_case.header, "utf-8"); 581 HttpContentDisposition content_disposition(test_case.header, "utf-8");
582 int result = content_disposition.parse_result_flags(); 582 int result = content_disposition.parse_result_flags();
583 583
584 SCOPED_TRACE(testing::Message() << "Test case " << i 584 SCOPED_TRACE(testing::Message() << "Test case " << i
585 << " with header " << test_case.header); 585 << " with header " << test_case.header);
586 EXPECT_EQ(test_case.expected_flags, result); 586 EXPECT_EQ(test_case.expected_flags, result);
587 } 587 }
588 } 588 }
589 589
590 } // namespace net 590 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698