要解决这个问题,你需要在你的代码中使用gtest框架提供的main函数。以下是一个示例:
#include
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
#include
#include "gtest/gtest.h"
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
#include
#include "gtest/gtest.h"
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
TEST(MyTest, Test1) {
// 编写测试用例
ASSERT_EQ(1 + 1, 2);
}
// 添加更多的测试用例...
g++ -o test test.cc -lgtest -lgtest_main
./test
这样,你就可以使用gtest框架运行你的测试代码了。
上一篇:安装了Graphviz之后无法执行dot命令。(“dot”没有布局引擎的支持。)
下一篇:安装了官网上的tailwindcss后,为什么启动时会出现“pluginsisnotafunction”的报错?如何解决这个问题?