TEST
TEST宏的作用是创建一个简单测试,他定义了一个测试函数,在该函数中可以使用任何C++代码并使用提供的断言来进行检查。
a) TEST(test_case_name, test_name)
b) TEST_F(test_fixture, test_name)
TestSuite级别
需要写一个类,继承testing::Test。然后实现两个静态方法:SetUpTestCase和TearDownTestCase,SetUpTestCase方法在第一个TestCase之前执行;TearDownTestCase方法在最后一个TestCase之后执行。
class test_rec_alarm : public testing::Test
{
protected:
static void SetUpTestCase();
static void TearDownTestCase();
INT32 test_rec_report_alarm_file(UINT32 camera_id, UINT32 frag_no, UINT32 markdata_time_stamp);
INT32 test_rec_release_alarm_file(UINT32 camera_id, UINT32 frag_no, UINT32 markdata_time_stamp);
INT32 test_rec_report_alarm_markdata_file_courrpted(CHAR* markdata_file_path);
INT32 test_rec_release_alarm_markdata_file_courrpted(CHAR* markdata_file_path);
INT32 test_rec_report_alarm_discard(UINT32 dau, UINT32 type);
INT32 test_rec_release_alarm_discard(UINT32 dau, UINT32 type);
protected:
};
TestCase级别
需要写一个类,继承testing::Test。然后实现两个虚方法:SetUp方法和TearDown方法,SetUp方法在每个TestCase之前执行;TearDown方法在每个TestCase之后执行。
class test_storage_period_store : public testing::Test
{
protected:
virtual void SetUp();
virtual void TearDown();
int node_add(void* node);
int node_delete(void* node);
int node_replace(void* node);
int node_count();
protected:
avl_tree_info_t* m_storage_period_info_tree;
};