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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/util/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/util/gtest_prod_utils.h
diff --git a/mojo/edk/util/gtest_prod_utils.h b/mojo/edk/util/gtest_prod_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..b02baaa76ee9a6431b61d39225954dc9e04b86ca
--- /dev/null
+++ b/mojo/edk/util/gtest_prod_utils.h
@@ -0,0 +1,52 @@
+// 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.
+
+// Utilities for (non-test) code to help with testing that code with gtest.
+// (Note that this file does not imply any dependency on gtest.)
+
+#ifndef MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
+#define MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
+
+// Like gtest's |FRIEND_TEST()| macro, but friends the given test with all
+// possible prefixes, so that when the test prefix is changed the friend
+// declarations won't need to be updated. For example:
+//
+// class MyClass {
+// private:
+// void MyMethod();
+// FRIEND_TEST_ALL_PREFIXES(MyClassTest, MyMethod);
+// };
+#define FRIEND_TEST_ALL_PREFIXES(test_case_name, test_name) \
+ friend class test_case_name##_##test_name##_Test; \
+ friend class test_case_name##_##DISABLED_##test_name##_Test; \
+ friend class test_case_name##_##FLAKY_##test_name##_Test
+
+// Macro to forward-declare tests (with all possible prefixes).
+//
+// C++ compilers will refuse to compile the following code:
+//
+// namespace foo {
+// class MyClass {
+// private:
+// 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 the |foo|
+// namespace. Use |FORWARD_DECLARE_TEST()| to do this. For example, in the code,
+// add the following at the top:
+//
+// FORWARD_DECLARE_TEST(MyClassTest, TestMethod);
+#define 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 // MOJO_EDK_UTIL_GTEST_PROD_UTILS_H_
« 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