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

Side by Side Diff: base/mac/call_with_eh_frame_unittest.mm

Issue 1212093002: [Mac] Redo NSException handling, and generate better stacks for C++ exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Align stack Created 5 years, 5 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 | « base/mac/call_with_eh_frame_asm.S ('k') | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/mac/call_with_eh_frame.h"
6
7 #import <Foundation/Foundation.h>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace base {
12 namespace mac {
13 namespace {
14
15 class CallWithEHFrameTest : public testing::Test {
16 protected:
17 void ThrowException() {
18 [NSArray arrayWithObject:nil];
19 }
20 };
21
22 // Catching from within the EHFrame is allowed.
23 TEST_F(CallWithEHFrameTest, CatchExceptionHigher) {
24 bool __block saw_exception = false;
25 base::mac::CallWithEHFrame(^{
26 @try {
27 ThrowException();
28 } @catch (NSException* exception) {
29 saw_exception = true;
30 }
31 });
32 EXPECT_TRUE(saw_exception);
33 }
34
35 // Trying to catch an exception outside the EHFrame is blocked.
36 TEST_F(CallWithEHFrameTest, CatchExceptionLower) {
37 auto catch_exception_lower = ^{
38 bool saw_exception = false;
39 @try {
40 base::mac::CallWithEHFrame(^{
41 ThrowException();
42 });
43 } @catch (NSException* exception) {
44 saw_exception = true;
45 }
46 ASSERT_FALSE(saw_exception);
47 };
48 EXPECT_DEATH(catch_exception_lower(), "");
49 }
50
51 } // namespace
52 } // namespace mac
53 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/call_with_eh_frame_asm.S ('k') | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698