John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame^] | 1 | #ifndef AOS_GTEST_PROD_H_ |
| 2 | #define AOS_GTEST_PROD_H_ |
brians | 2fdfc07 | 2013-02-26 05:35:15 +0000 | [diff] [blame] | 3 | |
brians | 2fdfc07 | 2013-02-26 05:35:15 +0000 | [diff] [blame] | 4 | // These macros replace gtest's FRIEND_TEST if the test is in a different |
| 5 | // namespace than the code that needs to make it a friend. |
| 6 | // Example: |
| 7 | // foo.h: |
| 8 | // namespace bla { |
| 9 | // namespace testing { |
| 10 | // |
| 11 | // FORWARD_DECLARE_TEST_CASE(FooTest, Bar); |
| 12 | // |
| 13 | // } // namespace testing |
| 14 | // |
| 15 | // class Foo { |
| 16 | // FRIEND_TEST_NAMESPACE(FooTest, Bar, testing); |
| 17 | // }; |
| 18 | // |
| 19 | // } // namespace bla |
| 20 | // foo_test.cc: |
| 21 | // namespace bla { |
| 22 | // namespace testing { |
| 23 | // |
| 24 | // TEST(FooTest, Bar) { |
| 25 | // access private members of Foo |
| 26 | // } |
| 27 | // |
| 28 | // } // namespace testing |
| 29 | // } // namespace bla |
| 30 | #define FORWARD_DECLARE_TEST_CASE(test_case_name, test_name) \ |
| 31 | class test_case_name##_##test_name##_Test; |
| 32 | #define FRIEND_TEST_NAMESPACE(test_case_name, test_name, namespace_name) \ |
| 33 | friend class namespace_name::test_case_name##_##test_name##_Test |
| 34 | |
Brian Silverman | ea54229 | 2015-09-13 02:24:45 -0400 | [diff] [blame] | 35 | // Copied from googletest's gtest_prod.h. See that file for documentation. |
| 36 | #define FRIEND_TEST(test_case_name, test_name) \ |
| 37 | friend class test_case_name##_##test_name##_Test |
| 38 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame^] | 39 | #endif // AOS_GTEST_PROD_H_ |