[英]How to test void function with pass by reference parameter using googletest?
This is the function that I have. 这就是我所拥有的功能。
int square(const int value)
{
return value * value;
}
void square2(const int value, int& output)
{
output = value * value;
}
I can test square without problem. 我可以毫无问题地测试正方形。 But how do I test square2?
但是我如何测试square2?
This is how I currently test. 这就是我目前的测试方式。
TEST(SquareTests, Square)
{
EXPECT_EQ(0, square(0));
EXPECT_EQ(4, square(-2));
}
TEST(SquareTests, SquareParameter)
{
//EXPECT_EQ(0, square2(0));
//EXPECT_EQ(4, square2(-2));
}
TEST(SquareTests, SquareParameterRef)
{
int result = -1;
square2(0, result);
EXPECT_EQ(0, result);
square2(-2, result);
EXPECT_EQ(4, result);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.