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