-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PA] Copy base/gtest_prod_util.h utils to PA library
PS7 = simple copy Bug: 1151236 Change-Id: I0772532eba3d00307b3cfd7bd9dcc993f9f7918b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3634978 Reviewed-by: Austin Sullivan <asully@chromium.org> Commit-Queue: Bartek Nowierski <bartekn@chromium.org> Reviewed-by: Takashi Sakamoto <tasak@google.com> Cr-Commit-Position: refs/heads/main@{#1002059}
- Loading branch information
1 parent
e0f9a38
commit d2db606
Showing
6 changed files
with
100 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
base/allocator/partition_allocator/partition_alloc_base/gtest_prod_util.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2012 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_BASE_GTEST_PROD_UTIL_H_ | ||
#define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_BASE_GTEST_PROD_UTIL_H_ | ||
|
||
#include "testing/gtest/include/gtest/gtest_prod.h" // nogncheck | ||
|
||
// This is a wrapper for gtest's FRIEND_TEST macro that friends | ||
// test with all possible prefixes. This is very helpful when changing the test | ||
// prefix, because the friend declarations don't need to be updated. | ||
// | ||
// Example usage: | ||
// | ||
// class MyClass { | ||
// private: | ||
// void MyMethod(); | ||
// PA_FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod); | ||
// }; | ||
#define PA_FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \ | ||
FRIEND_TEST(test_case_name, test_name); \ | ||
FRIEND_TEST(test_case_name, DISABLED_##test_name); \ | ||
FRIEND_TEST(test_case_name, FLAKY_##test_name) | ||
|
||
// C++ compilers will refuse to compile the following code: | ||
// | ||
// namespace foo { | ||
// class MyClass { | ||
// private: | ||
// PA_FRIEND_TEST_ALL_PREFIXES(MyClassTest, TestMethod); | ||
// bool private_var; | ||
// }; | ||
// } // namespace foo | ||
// | ||
// class MyClassTest::TestMethod() { | ||
// foo::MyClass foo_class; | ||
// foo_class.private_var = true; | ||
// } | ||
// | ||
// Unless you forward declare MyClassTest::TestMethod outside of namespace foo. | ||
// Use PA_FORWARD_DECLARE_TEST to do so for all possible prefixes. | ||
// | ||
// Example usage: | ||
// | ||
// PA_FORWARD_DECLARE_TEST(MyClassTest, TestMethod); | ||
// | ||
// namespace foo { | ||
// class MyClass { | ||
// private: | ||
// PA_FRIEND_TEST_ALL_PREFIXES(::MyClassTest, TestMethod); // NOTE use of :: | ||
// bool private_var; | ||
// }; | ||
// } // namespace foo | ||
// | ||
// class MyClassTest::TestMethod() { | ||
// foo::MyClass foo_class; | ||
// foo_class.private_var = true; | ||
// } | ||
|
||
#define PA_FORWARD_DECLARE_TEST(test_case_name, test_name) \ | ||
class test_case_name##_##test_name##_Test; \ | ||
class test_case_name##_##DISABLED_##test_name##_Test; \ | ||
class test_case_name##_##FLAKY_##test_name##_Test | ||
|
||
#endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ALLOC_BASE_GTEST_PROD_UTIL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters