上面配置好之后,我们写个测试用例跑一下。
#include <iostream>
#include <gtest/gtest.h>
int add(int a, int b)
{
return a + b;
}
int sub(int a, int b)
{
return a - b;
}
TEST(testcase, test_add)
{
EXPECT_EQ(add(1,2), 3);
EXPECT_EQ(sub(1,2), -1);
}
int main(int argc, char **argv)
{
std::cout << "run google test --> " << std::endl << std::endl;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}