1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_GTEST_PROD_UTIL_H_
6 #define BASE_GTEST_PROD_UTIL_H_
8 #include "testing/gtest/include/gtest/gtest_prod.h" // nogncheck
10 // This is a wrapper for gtest's FRIEND_TEST macro that friends
11 // test with all possible prefixes. This is very helpful when changing the test
12 // prefix, because the friend declarations don't need to be updated.
19 // FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod);
21 #define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \
22 FRIEND_TEST(test_case_name, test_name); \
23 FRIEND_TEST(test_case_name, DISABLED_##test_name); \
24 FRIEND_TEST(test_case_name, FLAKY_##test_name)
26 // C++ compilers will refuse to compile the following code:
31 // FRIEND_TEST_ALL_PREFIXES(MyClassTest, TestMethod);
36 // class MyClassTest::TestMethod() {
37 // foo::MyClass foo_class;
38 // foo_class.private_var = true;
41 // Unless you forward declare MyClassTest::TestMethod outside of namespace foo.
42 // Use FORWARD_DECLARE_TEST to do so for all possible prefixes.
46 // FORWARD_DECLARE_TEST(MyClassTest, TestMethod);
51 // FRIEND_TEST_ALL_PREFIXES(::MyClassTest, TestMethod); // NOTE use of ::
56 // class MyClassTest::TestMethod() {
57 // foo::MyClass foo_class;
58 // foo_class.private_var = true;
61 #define FORWARD_DECLARE_TEST(test_case_name, test_name) \
62 class test_case_name##_##test_name##_Test; \
63 class test_case_name##_##DISABLED_##test_name##_Test; \
64 class test_case_name##_##FLAKY_##test_name##_Test
66 #endif // BASE_GTEST_PROD_UTIL_H_