zoukankan      html  css  js  c++  java
  • CUNIT中的断言

    #include <CUnit/CUnit.h> (断言所在文件)

    CU_ASSERT(int expression)
    CU_ASSERT_FATAL(int expression)
    CU_TEST(int expression)
    CU_TEST_FATAL(int expression)

    Assert that expression is TRUE (non-zero)

    CU_ASSERT_TRUE(value)
    CU_ASSERT_TRUE_FATAL(value)

    Assert that value is TRUE (non-zero)

    CU_ASSERT_FALSE(value)
    CU_ASSERT_FALSE_FATAL(value)

    Assert that value is FALSE (zero)

    CU_ASSERT_EQUAL(actual, expected)
    CU_ASSERT_EQUAL_FATAL(actual, expected)

    Assert that actual = = expected

    CU_ASSERT_NOT_EQUAL(actual, expected))
    CU_ASSERT_NOT_EQUAL_FATAL(actual, expected)

    Assert that actual != expected

    CU_ASSERT_PTR_EQUAL(actual, expected)
    CU_ASSERT_PTR_EQUAL_FATAL(actual, expected)

    Assert that pointers actual = = expected

    CU_ASSERT_PTR_NOT_EQUAL(actual, expected)
    CU_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected)

    Assert that pointers actual != expected

    CU_ASSERT_PTR_NULL(value)
    CU_ASSERT_PTR_NULL_FATAL(value)

    Assert that pointer value == NULL

    CU_ASSERT_PTR_NOT_NULL(value)
    CU_ASSERT_PTR_NOT_NULL_FATAL(value)

    Assert that pointer value != NULL

    CU_ASSERT_STRING_EQUAL(actual, expected)
    CU_ASSERT_STRING_EQUAL_FATAL(actual, expected)

    Assert that strings actual and expected are equivalent

    CU_ASSERT_STRING_NOT_EQUAL(actual, expected)
    CU_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected)

    Assert that strings actual and expected differ

    CU_ASSERT_NSTRING_EQUAL(actual, expected, count)
    CU_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count)

    Assert that 1st count chars of actual and expected are the same

    CU_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count)
    CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count)

    Assert that 1st count chars of actual and expected differ

    CU_ASSERT_DOUBLE_EQUAL(actual, expected, granularity)
    CU_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity)

    Assert that |actual - expected| <= |granularity|
    Math library must be linked in for this assertion.

    CU_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity)
    CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity)

    Assert that |actual - expected| > |granularity|
    Math library must be linked in for this assertion.

    CU_PASS(message)

    Register a passing assertion with the specified message. No logical test is performed.

    CU_FAIL(message)
    CU_FAIL_FATAL(message)

    Register a failed assertion with the specified message. No logical test is performed.

    • 版本2断言:

    #include <CUnit/CUnit.h>(断言所在文件)

    Deprecated Name

    Equivalent New Name

    ASSERT

    CU_ASSERT_FATAL

    ASSERT_TRUE

    CU_ASSERT_TRUE_FATAL

    ASSERT_FALSE

    CU_ASSERT_FALSE_FATAL

    ASSERT_EQUAL

    CU_ASSERT_EQUAL_FATAL

    ASSERT_NOT_EQUAL

    CU_ASSERT_NOT_EQUAL_FATAL

    ASSERT_PTR_EQUAL

    CU_ASSERT_PTR_EQUAL_FATAL

    ASSERT_PTR_NOT_EQUAL

    CU_ASSERT_PTR_NOT_EQUAL_FATAL

    ASSERT_PTR_NULL

    CU_ASSERT_PTR_NULL_FATAL

    ASSERT_PTR_NOT_NULL

    CU_ASSERT_PTR_NOT_NULL_FATAL

    ASSERT_STRING_EQUAL

    CU_ASSERT_STRING_EQUAL_FATAL

    ASSERT_STRING_NOT_EQUAL

    CU_ASSERT_STRING_NOT_EQUAL_FATAL

    ASSERT_NSTRING_EQUAL

    CU_ASSERT_NSTRING_EQUAL_FATAL

    ASSERT_NSTRING_NOT_EQUAL

    CU_ASSERT_NSTRING_NOT_EQUAL_FATAL

    ASSERT_DOUBLE_EQUAL

    CU_ASSERT_DOUBLE_EQUAL_FATAL

    ASSERT_DOUBLE_NOT_EQUAL

    CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL

  • 相关阅读:
    Win10 企业版ltsc 无法访问samba网络共享问题及解决!(转)
    内核发送uevent的API,用户空间解析uevent(转)
    修改kile工程名字(转)
    gdb调试
    当usbnet打印 kevent * may have been dropped(转)
    收藏一份devmem源码
    Linux Performance
    控制 input框只输入数字
    springboot环境中,可能会出现使用font-Awesome结果图标不显示的问题,在webService的pom文件中添加如下配置代码
    js防止页面抖动(按钮,请求等重复提交)
  • 原文地址:https://www.cnblogs.com/iluzhiyong/p/2756306.html
Copyright © 2011-2022 走看看