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

Side by Side Diff: util/mach/exc_client_variants_test.cc

Issue 700383007: Use implicit_cast<> instead of static_cast<> whenever possible (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month 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
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,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 EXPECT_NE(THREAD_NULL, thread); 73 EXPECT_NE(THREAD_NULL, thread);
74 EXPECT_EQ(ChildTask(), task); 74 EXPECT_EQ(ChildTask(), task);
75 } else { 75 } else {
76 EXPECT_EQ(THREAD_NULL, thread); 76 EXPECT_EQ(THREAD_NULL, thread);
77 EXPECT_EQ(TASK_NULL, task); 77 EXPECT_EQ(TASK_NULL, task);
78 } 78 }
79 79
80 mach_exception_code_t expect_code = exception_code_; 80 mach_exception_code_t expect_code = exception_code_;
81 mach_exception_subcode_t expect_subcode = exception_subcode_; 81 mach_exception_subcode_t expect_subcode = exception_subcode_;
82 if ((behavior & MACH_EXCEPTION_CODES) == 0) { 82 if ((behavior & MACH_EXCEPTION_CODES) == 0) {
83 expect_code = static_cast<exception_data_type_t>(expect_code); 83 expect_code = implicit_cast<exception_data_type_t>(expect_code);
84 expect_subcode = static_cast<exception_data_type_t>(expect_subcode); 84 expect_subcode = implicit_cast<exception_data_type_t>(expect_subcode);
85 } 85 }
86 86
87 EXPECT_EQ(exception_, exception); 87 EXPECT_EQ(exception_, exception);
88 EXPECT_EQ(2u, code_count); 88 EXPECT_EQ(2u, code_count);
89 89
90 // The code_count check above would ideally use ASSERT_EQ so that the next 90 // The code_count check above would ideally use ASSERT_EQ so that the next
91 // conditionals would not be necessary, but ASSERT_* requires a function 91 // conditionals would not be necessary, but ASSERT_* requires a function
92 // returning type void, and the interface dictates otherwise here. 92 // returning type void, and the interface dictates otherwise here.
93 if (code_count >= 1) { 93 if (code_count >= 1) {
94 EXPECT_EQ(expect_code, code[0]); 94 EXPECT_EQ(expect_code, code[0]);
95 } 95 }
96 if (code_count >= 2) { 96 if (code_count >= 2) {
97 EXPECT_EQ(expect_subcode, code[1]); 97 EXPECT_EQ(expect_subcode, code[1]);
98 } 98 }
99 99
100 if (HasState()) { 100 if (HasState()) {
101 EXPECT_EQ(exception_ + 10, *flavor); 101 EXPECT_EQ(exception_ + 10, *flavor);
102 EXPECT_EQ(MACHINE_THREAD_STATE_COUNT, old_state_count); 102 EXPECT_EQ(MACHINE_THREAD_STATE_COUNT, old_state_count);
103 EXPECT_NE(nullptr, old_state); 103 EXPECT_NE(nullptr, old_state);
104 EXPECT_EQ(static_cast<mach_msg_type_number_t>(THREAD_STATE_MAX), 104 EXPECT_EQ(implicit_cast<mach_msg_type_number_t>(THREAD_STATE_MAX),
105 *new_state_count); 105 *new_state_count);
106 EXPECT_NE(nullptr, new_state); 106 EXPECT_NE(nullptr, new_state);
107 107
108 for (size_t index = 0; index < old_state_count; ++index) { 108 for (size_t index = 0; index < old_state_count; ++index) {
109 EXPECT_EQ(index, old_state[index]); 109 EXPECT_EQ(index, old_state[index]);
110 } 110 }
111 111
112 // Use a flavor known to be different from the incoming flavor, for a test 112 // Use a flavor known to be different from the incoming flavor, for a test
113 // of the “out” side of the inout flavor parameter. 113 // of the “out” side of the inout flavor parameter.
114 *flavor = exception_ + 20; 114 *flavor = exception_ + 20;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 TestExcClientVariants test_exc_client_variants(behavior, true); 282 TestExcClientVariants test_exc_client_variants(behavior, true);
283 test_exc_client_variants.Run(); 283 test_exc_client_variants.Run();
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288 } // namespace 288 } // namespace
289 } // namespace test 289 } // namespace test
290 } // namespace crashpad 290 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698