gtest學習筆記

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;
};

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章