OLD | NEW |
---|---|
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/strings/string_split.h" | 5 #include "base/strings/string_split.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
266 #else | 266 #else |
267 if (extensions[j] == tests[i].contained_result) | 267 if (extensions[j] == tests[i].contained_result) |
268 found = true; | 268 found = true; |
269 #endif | 269 #endif |
270 } | 270 } |
271 ASSERT_TRUE(found) << "Must find at least the contained result within " | 271 ASSERT_TRUE(found) << "Must find at least the contained result within " |
272 << tests[i].mime_type; | 272 << tests[i].mime_type; |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 TEST(MimeUtilTest, TestGenerateMimeMultipartBoundary) { | |
277 std::string boundary1 = GenerateMimeMultipartBoundary(); | |
278 std::string boundary2 = GenerateMimeMultipartBoundary(); | |
279 EXPECT_GT(70u, boundary1.size()); | |
280 EXPECT_GT(70u, boundary2.size()); | |
281 EXPECT_TRUE(boundary1.find("MultipartBoundary") != std::string::npos); | |
282 EXPECT_TRUE(boundary2.find("MultipartBoundary") != std::string::npos); | |
Ryan Sleevi
2015/12/28 23:30:00
EXPECT_NE ?
Łukasz Anforowicz
2015/12/29 18:53:19
Done + also tweaked the other asserts, added a few
| |
283 EXPECT_NE(boundary1, boundary2); | |
284 } | |
276 | 285 |
277 TEST(MimeUtilTest, TestAddMultipartValueForUpload) { | 286 TEST(MimeUtilTest, TestAddMultipartValueForUpload) { |
278 const char ref_output[] = | 287 const char ref_output[] = |
279 "--boundary\r\nContent-Disposition: form-data;" | 288 "--boundary\r\nContent-Disposition: form-data;" |
280 " name=\"value name\"\r\nContent-Type: content type" | 289 " name=\"value name\"\r\nContent-Type: content type" |
281 "\r\n\r\nvalue\r\n" | 290 "\r\n\r\nvalue\r\n" |
282 "--boundary\r\nContent-Disposition: form-data;" | 291 "--boundary\r\nContent-Disposition: form-data;" |
283 " name=\"value name\"\r\n\r\nvalue\r\n" | 292 " name=\"value name\"\r\n\r\nvalue\r\n" |
284 "--boundary--\r\n"; | 293 "--boundary--\r\n"; |
285 std::string post_data; | 294 std::string post_data; |
286 AddMultipartValueForUpload("value name", "value", "boundary", | 295 AddMultipartValueForUpload("value name", "value", "boundary", |
287 "content type", &post_data); | 296 "content type", &post_data); |
288 AddMultipartValueForUpload("value name", "value", "boundary", | 297 AddMultipartValueForUpload("value name", "value", "boundary", |
289 "", &post_data); | 298 "", &post_data); |
290 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | 299 AddMultipartFinalDelimiterForUpload("boundary", &post_data); |
291 EXPECT_STREQ(ref_output, post_data.c_str()); | 300 EXPECT_STREQ(ref_output, post_data.c_str()); |
292 } | 301 } |
293 | 302 |
294 } // namespace net | 303 } // namespace net |
OLD | NEW |