gtest学习笔记

1 篇文章 0 订阅

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

heibao111728

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值