标签:style dba 崩溃 wiki 区域 工作 bar 运行 安装
gtest/gtest.h
,你的gtest安装在GTEST_ROOT路径下""
是不相等的。TEST(test_case_name, test_name) {
... test body ...
}
TEST_F(test_case_name, test_name) {
... test body ...
}// test_case_name 必须是定义的test fixture类的名称
如果要触发运行,请执行RUN_ALL_TESTS()宏,如果所有的test都测试通过,它会返回0,否则会返回1。
#include "this/package/foo.h"
#include "gtest/gtest.h"
namespace {
// The fixture for testing class Foo.
class FooTest : public ::testing::Test {
protected:
// You can remove any or all of the following functions if its body is empty.
FooTest() {
// You can do set-up work for each test here.
}
Virtual ~FooTest() {
// You can do clean-up work that doesn‘t throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
virtual void SetUp() {
// Code here will be called immediately after the constructor
}
virtual void TearDown() {
// Code here will be called immediately after each test
}
// Object declared here can be used by all tests in the test case for Foo.
};
// Tests that the Foo::Bar() method does Abc.
TEST_F(FooTest, MethodBarDoesAbc) {
const string input_filepath = "this/package/testdata/myinputfile.dat";
const string output_filepath = "this/package/testdata/myoutputfile.dat";
Foo f;
EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
}
// Tests that Foo does Xyz.
TEST_F(FooTest, DoesXyz) {
// Execises the Xyz feature of Foo.
}
} // namespace
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
标签:style dba 崩溃 wiki 区域 工作 bar 运行 安装
原文地址:https://www.cnblogs.com/lizhensheng/p/11117280.html