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

Side by Side Diff: net/base/mime_util_unittest.cc

Issue 2943703002: Use ContainsValue() instead of std::find() in net/ (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | net/base/network_throttle_manager_impl.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/base/mime_util.h" 5 #include "net/base/mime_util.h"
6 6
7 #include <algorithm> 7 #include "base/stl_util.h"
8
9 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
10 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 10 #include "build/build_config.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 12
14 namespace net { 13 namespace net {
15 14
16 TEST(MimeUtilTest, ExtensionTest) { 15 TEST(MimeUtilTest, ExtensionTest) {
17 // String: png\0css 16 // String: png\0css
18 base::FilePath::StringType containsNullByte; 17 base::FilePath::StringType containsNullByte;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 265
267 if (test.no_matches) 266 if (test.no_matches)
268 ASSERT_EQ(0u, extensions.size()); 267 ASSERT_EQ(0u, extensions.size());
269 268
270 if (test.contained_result) { 269 if (test.contained_result) {
271 // Convert ASCII to FilePath::StringType. 270 // Convert ASCII to FilePath::StringType.
272 base::FilePath::StringType contained_result( 271 base::FilePath::StringType contained_result(
273 test.contained_result, 272 test.contained_result,
274 test.contained_result + strlen(test.contained_result)); 273 test.contained_result + strlen(test.contained_result));
275 274
276 bool found = std::find(extensions.begin(), extensions.end(), 275 bool found = base::ContainsValue(extensions, contained_result);
277 contained_result) != extensions.end();
278 276
279 ASSERT_TRUE(found) << "Must find at least the contained result within " 277 ASSERT_TRUE(found) << "Must find at least the contained result within "
280 << test.mime_type; 278 << test.mime_type;
281 } 279 }
282 } 280 }
283 } 281 }
284 282
285 TEST(MimeUtilTest, TestGenerateMimeMultipartBoundary) { 283 TEST(MimeUtilTest, TestGenerateMimeMultipartBoundary) {
286 std::string boundary1 = GenerateMimeMultipartBoundary(); 284 std::string boundary1 = GenerateMimeMultipartBoundary();
287 std::string boundary2 = GenerateMimeMultipartBoundary(); 285 std::string boundary2 = GenerateMimeMultipartBoundary();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 std::string post_data; 320 std::string post_data;
323 AddMultipartValueForUpload("value name", "value", "boundary", 321 AddMultipartValueForUpload("value name", "value", "boundary",
324 "content type", &post_data); 322 "content type", &post_data);
325 AddMultipartValueForUpload("value name", "value", "boundary", 323 AddMultipartValueForUpload("value name", "value", "boundary",
326 "", &post_data); 324 "", &post_data);
327 AddMultipartFinalDelimiterForUpload("boundary", &post_data); 325 AddMultipartFinalDelimiterForUpload("boundary", &post_data);
328 EXPECT_STREQ(ref_output, post_data.c_str()); 326 EXPECT_STREQ(ref_output, post_data.c_str());
329 } 327 }
330 328
331 } // namespace net 329 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/base/network_throttle_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698