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

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

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
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() { [NSArray arrayWithObject:nil]; }
18 };
19
20 // Catching from within the EHFrame is allowed.
21 TEST_F(CallWithEHFrameTest, CatchExceptionHigher) {
22 bool __block saw_exception = false;
23 base::mac::CallWithEHFrame(^{
24 @try {
25 ThrowException();
26 } @catch (NSException* exception) {
27 saw_exception = true;
28 }
29 });
30 EXPECT_TRUE(saw_exception);
31 }
32
33 // Trying to catch an exception outside the EHFrame is blocked.
34 TEST_F(CallWithEHFrameTest, CatchExceptionLower) {
35 auto catch_exception_lower = ^{
36 bool saw_exception = false;
37 @try {
38 base::mac::CallWithEHFrame(^{
39 ThrowException();
40 });
41 } @catch (NSException* exception) {
42 saw_exception = true;
43 }
44 ASSERT_FALSE(saw_exception);
45 };
46 EXPECT_DEATH(catch_exception_lower(), "");
47 }
48
49 } // namespace
50 } // namespace mac
51 } // namespace base
OLDNEW
« no previous file with comments | « base/mac/call_with_eh_frame_asm.S ('k') | base/mac/mac_util.h » ('j') | gin/modules/console.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698