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

Side by Side Diff: mojo/edk/util/gtest_prod_utils.h

Issue 1681173002: Fork //base/gtest_prod_util.h into //mojo/edk/util/gtest_prod_utils.h. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Utilities for (non-test) code to help with testing that code with gtest.
6 // (Note that this file does not imply any dependency on gtest.)
7
8 #ifndef MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
9 #define MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
10
11 // Like gtest's |FRIEND_TEST()| macro, but friends the given test with all
12 // possible prefixes, so that when the test prefix is changed the friend
13 // declarations won't need to be updated. For example:
14 //
15 // class MyClass {
16 // private:
17 // void MyMethod();
18 // FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod);
19 // };
20 #define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \
21 friend class test_case_name##_##test_name##_Test; \
22 friend class test_case_name##_##DISABLED_##test_name##_Test; \
23 friend class test_case_name##_##FLAKY_##test_name##_Test
24
25 // Macro to forward-declare tests (with all possible prefixes).
26 //
27 // C++ compilers will refuse to compile the following code:
28 //
29 // namespace foo {
30 // class MyClass {
31 // private:
32 // FRIEND_TEST_ALL_PREFIXES(MyClassTest, TestMethod);
33 // bool private_var;
34 // };
35 // } // namespace foo
36 //
37 // class MyClassTest::TestMethod() {
38 // foo::MyClass foo_class;
39 // foo_class.private_var = true;
40 // }
41 //
42 // unless you forward-declare |MyClassTest::TestMethod| outside of the |foo|
43 // namespace. Use |FORWARD_DECLARE_TEST()| to do this. For example, in the code,
44 // add the following at the top:
45 //
46 // FORWARD_DECLARE_TEST(MyClassTest, TestMethod);
47 #define FORWARD_DECLARE_TEST(test_case_name, test_name) \
48 class test_case_name##_##test_name##_Test; \
49 class test_case_name##_##DISABLED_##test_name##_Test; \
50 class test_case_name##_##FLAKY_##test_name##_Test
51
52 #endif // MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698