Zephyr Project API 4.0.99
A Scalable Open Source RTOS
|
This module provides assertions when using Ztest. More...
Macros | |
#define | zassert(cond, default_msg, ...) _zassert_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |
#define | zassume(cond, default_msg, ...) _zassume_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |
#define | zexpect(cond, default_msg, ...) _zexpect_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |
#define | zassert_unreachable(...) zassert(0, "Reached unreachable code", ##__VA_ARGS__) |
Assert that this function call won't be reached. | |
#define | zassert_true(cond, ...) zassert(cond, #cond " is false", ##__VA_ARGS__) |
Assert that cond is true. | |
#define | zassert_false(cond, ...) zassert(!(cond), #cond " is true", ##__VA_ARGS__) |
Assert that cond is false. | |
#define | zassert_ok(cond, ...) zassert(!(cond), #cond " is non-zero", ##__VA_ARGS__) |
Assert that cond is 0 (success) | |
#define | zassert_not_ok(cond, ...) zassert(!!(cond), #cond " is zero", ##__VA_ARGS__) |
Assert that cond is not 0 (failure) | |
#define | zassert_is_null(ptr, ...) zassert((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__) |
Assert that ptr is NULL. | |
#define | zassert_not_null(ptr, ...) zassert((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__) |
Assert that ptr is not NULL. | |
#define | zassert_equal(a, b, ...) zassert((a) == (b), #a " not equal to " #b, ##__VA_ARGS__) |
Assert that a equals b. | |
#define | zassert_not_equal(a, b, ...) zassert((a) != (b), #a " equal to " #b, ##__VA_ARGS__) |
Assert that a does not equal b. | |
#define | zassert_equal_ptr(a, b, ...) zassert((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__) |
Assert that a equals b. | |
#define | zassert_within(a, b, d, ...) |
Assert that a is within b with delta d. | |
#define | zassert_between_inclusive(a, l, u, ...) |
Assert that a is greater than or equal to l and less than or equal to u. | |
#define | zassert_mem_equal(...) zassert_mem_equal__(__VA_ARGS__) |
Assert that 2 memory buffers have the same contents. | |
#define | zassert_mem_equal__(buf, exp, size, ...) zassert(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__) |
Internal assert that 2 memory buffers have the same contents. | |
#define | zassert_str_equal(s1, s2, ...) zassert(strcmp(s1, s2) == 0, #s1 " not equal to " #s2, ##__VA_ARGS__) |
Assert that 2 strings have the same contents. | |
This module provides assertions when using Ztest.
#define zassert | ( | cond, | |
default_msg, | |||
... | |||
) | _zassert_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |
#define zassert_between_inclusive | ( | a, | |
l, | |||
u, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that a is greater than or equal to l and less than or equal to u.
a | Value to compare |
l | Lower limit |
u | Upper limit |
... | Optional message and variables to print if the assertion fails |
#define zassert_equal | ( | a, | |
b, | |||
... | |||
) | zassert((a) == (b), #a " not equal to " #b, ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that a equals b.
a and b won't be converted and will be compared directly.
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assertion fails |
#define zassert_equal_ptr | ( | a, | |
b, | |||
... | |||
) | zassert((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that a equals b.
a and b will be converted to void *
before comparing.
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assertion fails |
#define zassert_false | ( | cond, | |
... | |||
) | zassert(!(cond), #cond " is true", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that cond is false.
cond | Condition to check |
... | Optional message and variables to print if the assertion fails |
#define zassert_is_null | ( | ptr, | |
... | |||
) | zassert((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that ptr is NULL.
ptr | Pointer to compare |
... | Optional message and variables to print if the assertion fails |
#define zassert_mem_equal | ( | ... | ) | zassert_mem_equal__(__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that 2 memory buffers have the same contents.
This macro calls the final memory comparison assertion macro. Using double expansion allows providing some arguments by macros that would expand to more than one values (ANSI-C99 defines that all the macro arguments have to be expanded before macro call).
... | Arguments, see zassert_mem_equal__ for real arguments accepted. |
#define zassert_mem_equal__ | ( | buf, | |
exp, | |||
size, | |||
... | |||
) | zassert(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Internal assert that 2 memory buffers have the same contents.
buf | Buffer to compare |
exp | Buffer with expected contents |
size | Size of buffers |
... | Optional message and variables to print if the assertion fails |
#define zassert_not_equal | ( | a, | |
b, | |||
... | |||
) | zassert((a) != (b), #a " equal to " #b, ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that a does not equal b.
a and b won't be converted and will be compared directly.
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assertion fails |
#define zassert_not_null | ( | ptr, | |
... | |||
) | zassert((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that ptr is not NULL.
ptr | Pointer to compare |
... | Optional message and variables to print if the assertion fails |
#define zassert_not_ok | ( | cond, | |
... | |||
) | zassert(!!(cond), #cond " is zero", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that cond is not 0 (failure)
cond | Condition to check |
... | Optional message and variables to print if the assertion fails |
#define zassert_ok | ( | cond, | |
... | |||
) | zassert(!(cond), #cond " is non-zero", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that cond is 0 (success)
cond | Condition to check |
... | Optional message and variables to print if the assertion fails |
#define zassert_str_equal | ( | s1, | |
s2, | |||
... | |||
) | zassert(strcmp(s1, s2) == 0, #s1 " not equal to " #s2, ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that 2 strings have the same contents.
s1 | The first string |
s2 | The second string |
... | Optional message and variables to print if the expectation fails |
#define zassert_true | ( | cond, | |
... | |||
) | zassert(cond, #cond " is false", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that cond is true.
cond | Condition to check |
... | Optional message and variables to print if the assertion fails |
#define zassert_unreachable | ( | ... | ) | zassert(0, "Reached unreachable code", ##__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that this function call won't be reached.
... | Optional message and variables to print if the assertion fails |
#define zassert_within | ( | a, | |
b, | |||
d, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assert that a is within b with delta d.
a | Value to compare |
b | Value to compare |
d | Delta |
... | Optional message and variables to print if the assertion fails |
#define zassume | ( | cond, | |
default_msg, | |||
... | |||
) | _zassume_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |
#define zexpect | ( | cond, | |
default_msg, | |||
... | |||
) | _zexpect_va(cond, default_msg, COND_CODE_1(__VA_OPT__(1), (__VA_ARGS__), (NULL))) |