[英]How do I use FRIEND_TEST with TYPED_TEST in Google Test?
In Google Test, I know how to use FRIEND_TEST.在 Google Test 中,我知道如何使用 FRIEND_TEST。
And I know how to use TYPED_TEST.而且我知道如何使用 TYPED_TEST。
But how do you make a TYPED_TEST also be a FRIEND_TEST?但是如何使 TYPED_TEST 也成为 FRIEND_TEST?
在FRIEND_TEST
声明的前面添加template <typename T>
对我FRIEND_TEST
。
Let's take this example:让我们举个例子:
namespace Test
{
template<typename ClassA>
class TestClassA;
template<typename Class>
class GTEST_TEST_CLASS_NAME_(TestClassA, TestMethodOne);
template<typename Class>
class GTEST_TEST_CLASS_NAME_(TestClassA, TestMethodTwo);
}
Now, you need to define a macro
for the test friend like this:现在,您需要像这样为测试朋友定义一个
macro
:
#define CLASS_A_TEST_FRIENDS \
template<typename ObjectLocator> \
friend class ::Test::TestClassA; \
FRIEND_TEST(::Test::TestClassA, TestMethodOne); \
FRIEND_TEST(::Test::TestClassA, TestMethodTwo);
And then continue your work with the typed test.然后继续您的输入测试工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.