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

Side by Side Diff: util/net/http_multipart_builder_test.cc

Issue 992693003: Add ASSERT_DEATH_CHECK() to do ASSERT_DEATH() of CHECK() failures (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 5 years, 9 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 | « util/misc/scoped_forbid_return_test.cc ('k') | util/test/gtest_death_check.h » ('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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/net/http_multipart_builder.h" 15 #include "util/net/http_multipart_builder.h"
16 16
17 #include <vector> 17 #include <vector>
18 18
19 #include "gtest/gtest.h" 19 #include "gtest/gtest.h"
20 #include "util/net/http_body.h" 20 #include "util/net/http_body.h"
21 #include "util/net/http_body_test_util.h" 21 #include "util/net/http_body_test_util.h"
22 #include "util/test/gtest_death_check.h"
22 #include "util/test/paths.h" 23 #include "util/test/paths.h"
23 24
24 namespace crashpad { 25 namespace crashpad {
25 namespace test { 26 namespace test {
26 namespace { 27 namespace {
27 28
28 std::vector<std::string> SplitCRLF(const std::string& string) { 29 std::vector<std::string> SplitCRLF(const std::string& string) {
29 std::vector<std::string> lines; 30 std::vector<std::string> lines;
30 size_t last_line = 0; 31 size_t last_line = 0;
31 for (size_t i = 0; i < string.length(); ++i) { 32 for (size_t i = 0; i < string.length(); ++i) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 EXPECT_EQ(kValue1, *lines_it++); 267 EXPECT_EQ(kValue1, *lines_it++);
267 268
268 EXPECT_EQ(boundary + "--", *lines_it++); 269 EXPECT_EQ(boundary + "--", *lines_it++);
269 270
270 EXPECT_EQ(lines.end(), lines_it); 271 EXPECT_EQ(lines.end(), lines_it);
271 } 272 }
272 273
273 TEST(HTTPMultipartBuilderDeathTest, AssertUnsafeMIMEType) { 274 TEST(HTTPMultipartBuilderDeathTest, AssertUnsafeMIMEType) {
274 HTTPMultipartBuilder builder; 275 HTTPMultipartBuilder builder;
275 // Invalid and potentially dangerous: 276 // Invalid and potentially dangerous:
276 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "\r\n"), ""); 277 ASSERT_DEATH_CHECK(
277 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "\""), ""); 278 builder.SetFileAttachment("", "", base::FilePath(), "\r\n"), "");
278 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "\x12"), ""); 279 ASSERT_DEATH_CHECK(
279 ASSERT_DEATH(builder.SetFileAttachment("", "", base::FilePath(), "<>"), ""); 280 builder.SetFileAttachment("", "", base::FilePath(), "\""), "");
281 ASSERT_DEATH_CHECK(
282 builder.SetFileAttachment("", "", base::FilePath(), "\x12"), "");
283 ASSERT_DEATH_CHECK(
284 builder.SetFileAttachment("", "", base::FilePath(), "<>"), "");
280 // Invalid but safe: 285 // Invalid but safe:
281 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf"); 286 builder.SetFileAttachment("", "", base::FilePath(), "0/totally/-invalid.pdf");
282 // Valid and safe: 287 // Valid and safe:
283 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml"); 288 builder.SetFileAttachment("", "", base::FilePath(), "application/xml+xhtml");
284 } 289 }
285 290
286 } // namespace 291 } // namespace
287 } // namespace test 292 } // namespace test
288 } // namespace crashpad 293 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/misc/scoped_forbid_return_test.cc ('k') | util/test/gtest_death_check.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698