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

Side by Side Diff: chrome/browser/extensions/api/web_request/form_data_parser_unittest.cc

Issue 16703018: Rewrite scoped_ptr<T>(NULL) to use the default ctor in chrome/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/strings/string_piece.h" 6 #include "base/strings/string_piece.h"
7 #include "chrome/browser/extensions/api/web_request/form_data_parser.h" 7 #include "chrome/browser/extensions/api/web_request/form_data_parser.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 namespace { 12 namespace {
13 13
14 // Attempts to create a parser corresponding to the |content_type_header|. 14 // Attempts to create a parser corresponding to the |content_type_header|.
15 // On success, returns the parser. 15 // On success, returns the parser.
16 scoped_ptr<FormDataParser> InitParser( 16 scoped_ptr<FormDataParser> InitParser(
17 const std::string& content_type_header, 17 const std::string& content_type_header,
18 std::vector<std::string>* output) { 18 std::vector<std::string>* output) {
19 if (output == NULL) 19 if (output == NULL)
20 return scoped_ptr<FormDataParser>(NULL); 20 return scoped_ptr<FormDataParser>();
21 output->clear(); 21 output->clear();
22 scoped_ptr<FormDataParser> parser( 22 scoped_ptr<FormDataParser> parser(
23 FormDataParser::CreateFromContentTypeHeader(&content_type_header)); 23 FormDataParser::CreateFromContentTypeHeader(&content_type_header));
24 if (parser.get() == NULL) 24 if (parser.get() == NULL)
25 return scoped_ptr<FormDataParser>(NULL); 25 return scoped_ptr<FormDataParser>();
26 return parser.Pass(); 26 return parser.Pass();
27 } 27 }
28 28
29 // Attempts to run the parser corresponding to the |content_type_header| 29 // Attempts to run the parser corresponding to the |content_type_header|
30 // on the source represented by the concatenation of blocks from |bytes|. 30 // on the source represented by the concatenation of blocks from |bytes|.
31 // On success, returns true and the parsed |output|, else false. 31 // On success, returns true and the parsed |output|, else false.
32 // Parsed |output| has names on even positions (0, 2, ...), values on odd ones. 32 // Parsed |output| has names on even positions (0, 2, ...), values on odd ones.
33 bool RunParser(const std::string& content_type_header, 33 bool RunParser(const std::string& content_type_header,
34 const std::vector<const base::StringPiece*>& bytes, 34 const std::vector<const base::StringPiece*>& bytes,
35 std::vector<std::string>* output) { 35 std::vector<std::string>* output) {
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 // Fourth test: empty URL-encoded POST data. Note that an empty string is a 230 // Fourth test: empty URL-encoded POST data. Note that an empty string is a
231 // valid url-encoded value, so this should parse correctly. 231 // valid url-encoded value, so this should parse correctly.
232 std::vector<std::string> output; 232 std::vector<std::string> output;
233 input.clear(); 233 input.clear();
234 input.push_back(&kUrlEncodedBytesEmpty); 234 input.push_back(&kUrlEncodedBytesEmpty);
235 EXPECT_TRUE(RunParser(kUrlEncoded, input, &output)); 235 EXPECT_TRUE(RunParser(kUrlEncoded, input, &output));
236 EXPECT_EQ(0u, output.size()); 236 EXPECT_EQ(0u, output.size());
237 } 237 }
238 238
239 } // namespace extensions 239 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698