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

Side by Side Diff: content/child/multipart_response_delegate_unittest.cc

Issue 654403002: Convert ARRAYSIZE_UNSAFE -> arraysize in content/. (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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/child/multipart_response_delegate.h" 5 #include "content/child/multipart_response_delegate.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/public/platform/WebString.h" 10 #include "third_party/WebKit/public/platform/WebString.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 { "\r\nLine", 0, 2 }, 115 { "\r\nLine", 0, 2 },
116 { "\nLine", 0, 1 }, 116 { "\nLine", 0, 1 },
117 { "\n\nLine", 0, 2 }, 117 { "\n\nLine", 0, 2 },
118 { "\rLine", 0, 1 }, 118 { "\rLine", 0, 1 },
119 { "Line\r\nLine", 4, 2 }, 119 { "Line\r\nLine", 4, 2 },
120 { "Line\nLine", 4, 1 }, 120 { "Line\nLine", 4, 1 },
121 { "Line\n\nLine", 4, 2 }, 121 { "Line\n\nLine", 4, 2 },
122 { "Line\rLine", 4, 1 }, 122 { "Line\rLine", 4, 1 },
123 { "Line\r\rLine", 4, 1 }, 123 { "Line\r\rLine", 4, 1 },
124 }; 124 };
125 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(line_tests); ++i) { 125 for (size_t i = 0; i < arraysize(line_tests); ++i) {
126 EXPECT_EQ(line_tests[i].expected, 126 EXPECT_EQ(line_tests[i].expected,
127 delegate_tester.PushOverLine(line_tests[i].input, 127 delegate_tester.PushOverLine(line_tests[i].input,
128 line_tests[i].position)); 128 line_tests[i].position));
129 } 129 }
130 130
131 // ParseHeaders tests 131 // ParseHeaders tests
132 struct { 132 struct {
133 const char* data; 133 const char* data;
134 const bool rv; 134 const bool rv;
135 const int received_response_calls; 135 const int received_response_calls;
136 const char* newdata; 136 const char* newdata;
137 } header_tests[] = { 137 } header_tests[] = {
138 { "This is junk", false, 0, "This is junk" }, 138 { "This is junk", false, 0, "This is junk" },
139 { "Foo: bar\nBaz:\n\nAfter:\n", true, 1, "After:\n" }, 139 { "Foo: bar\nBaz:\n\nAfter:\n", true, 1, "After:\n" },
140 { "Foo: bar\nBaz:\n", false, 0, "Foo: bar\nBaz:\n" }, 140 { "Foo: bar\nBaz:\n", false, 0, "Foo: bar\nBaz:\n" },
141 { "Foo: bar\r\nBaz:\r\n\r\nAfter:\r\n", true, 1, "After:\r\n" }, 141 { "Foo: bar\r\nBaz:\r\n\r\nAfter:\r\n", true, 1, "After:\r\n" },
142 { "Foo: bar\r\nBaz:\r\n", false, 0, "Foo: bar\r\nBaz:\r\n" }, 142 { "Foo: bar\r\nBaz:\r\n", false, 0, "Foo: bar\r\nBaz:\r\n" },
143 { "Foo: bar\nBaz:\r\n\r\nAfter:\n\n", true, 1, "After:\n\n" }, 143 { "Foo: bar\nBaz:\r\n\r\nAfter:\n\n", true, 1, "After:\n\n" },
144 { "Foo: bar\r\nBaz:\n", false, 0, "Foo: bar\r\nBaz:\n" }, 144 { "Foo: bar\r\nBaz:\n", false, 0, "Foo: bar\r\nBaz:\n" },
145 { "\r\n", true, 1, "" }, 145 { "\r\n", true, 1, "" },
146 }; 146 };
147 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(header_tests); ++i) { 147 for (size_t i = 0; i < arraysize(header_tests); ++i) {
148 client.Reset(); 148 client.Reset();
149 delegate_tester.data().assign(header_tests[i].data); 149 delegate_tester.data().assign(header_tests[i].data);
150 EXPECT_EQ(header_tests[i].rv, 150 EXPECT_EQ(header_tests[i].rv,
151 delegate_tester.ParseHeaders()); 151 delegate_tester.ParseHeaders());
152 EXPECT_EQ(header_tests[i].received_response_calls, 152 EXPECT_EQ(header_tests[i].received_response_calls,
153 client.received_response_); 153 client.received_response_);
154 EXPECT_EQ(string(header_tests[i].newdata), 154 EXPECT_EQ(string(header_tests[i].newdata),
155 delegate_tester.data()); 155 delegate_tester.data());
156 } 156 }
157 // Test that the resource response is filled in correctly when parsing 157 // Test that the resource response is filled in correctly when parsing
(...skipping 25 matching lines...) Expand all
183 const char* data; 183 const char* data;
184 const size_t position; 184 const size_t position;
185 } boundary_tests[] = { 185 } boundary_tests[] = {
186 { "bound", "bound", 0 }, 186 { "bound", "bound", 0 },
187 { "bound", "--bound", 0 }, 187 { "bound", "--bound", 0 },
188 { "bound", "junkbound", 4 }, 188 { "bound", "junkbound", 4 },
189 { "bound", "junk--bound", 4 }, 189 { "bound", "junk--bound", 4 },
190 { "foo", "bound", string::npos }, 190 { "foo", "bound", string::npos },
191 { "bound", "--boundbound", 0 }, 191 { "bound", "--boundbound", 0 },
192 }; 192 };
193 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(boundary_tests); ++i) { 193 for (size_t i = 0; i < arraysize(boundary_tests); ++i) {
194 delegate_tester.boundary().assign(boundary_tests[i].boundary); 194 delegate_tester.boundary().assign(boundary_tests[i].boundary);
195 delegate_tester.data().assign(boundary_tests[i].data); 195 delegate_tester.data().assign(boundary_tests[i].data);
196 EXPECT_EQ(boundary_tests[i].position, 196 EXPECT_EQ(boundary_tests[i].position,
197 delegate_tester.FindBoundary()); 197 delegate_tester.FindBoundary());
198 } 198 }
199 } 199 }
200 200
201 TEST(MultipartResponseTest, MissingBoundaries) { 201 TEST(MultipartResponseTest, MissingBoundaries) {
202 WebURLResponse response; 202 WebURLResponse response;
203 response.initialize(); 203 response.initialize();
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 EXPECT_EQ(2, client.received_response_); 665 EXPECT_EQ(2, client.received_response_);
666 EXPECT_EQ(string("response data2"), client.data_); 666 EXPECT_EQ(string("response data2"), client.data_);
667 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()), 667 EXPECT_EQ(static_cast<int>(data.length()) + static_cast<int>(data2.length()),
668 client.total_encoded_data_length_); 668 client.total_encoded_data_length_);
669 EXPECT_TRUE(client.response_.isMultipartPayload()); 669 EXPECT_TRUE(client.response_.isMultipartPayload());
670 } 670 }
671 671
672 } // namespace 672 } // namespace
673 673
674 } // namespace content 674 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_data_source_impl.cc ('k') | content/child/webcrypto/test/aes_cbc_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698