私有函数怎么测?
What is the best way of testing private methods with GoogleTest? [closed]
OPTION 2 修正后
/*example*/
class Foo
{
public:
Foo(){}
friend class FooTest;
private:
int bar(){return 1;}
};
class FooTest : public ::testing::Test
{
public:
FooTest(){}
int bar() { return foo.bar();}
private:
void TestBody(){}
private:
Foo foo;
};
TEST(FooTest, ALL)
{
FooTest ft;
EXPECT_EQ(ft.bar(), 1);
}
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}