这是我所拥有的功能。
int square(const int value)
{
return value * value;
}
void square2(const int value, int& output)
{
output = value * value;
}
我可以毫无问题地测试正方形。但是我如何测试square2?
这是我目前的测试方式。
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));
}
答案 0 :(得分:3)
TEST(SquareTests, SquareParameterRef)
{
int result = -1;
square2(0, result);
EXPECT_EQ(0, result);
square2(-2, result);
EXPECT_EQ(4, result);
}