Zephyr API Documentation 3.7.99
A Scalable Open Source RTOS
|
This module provides assertions when using Ztest. More...
Macros | |
#define | zassert(cond, default_msg, ...) |
#define | zassume(cond, default_msg, ...) |
#define | zexpect(cond, default_msg, ...) |
#define | zassert_unreachable(...) |
Assert that this function call won't be reached. | |
#define | zassert_true(cond, ...) |
Assert that cond is true. | |
#define | zassert_false(cond, ...) |
Assert that cond is false. | |
#define | zassert_ok(cond, ...) |
Assert that cond is 0 (success) | |
#define | zassert_not_ok(cond, ...) |
Assert that cond is not 0 (failure) | |
#define | zassert_is_null(ptr, ...) |
Assert that ptr is NULL. | |
#define | zassert_not_null(ptr, ...) |
Assert that ptr is not NULL. | |
#define | zassert_equal(a, b, ...) |
Assert that a equals b. | |
#define | zassert_not_equal(a, b, ...) |
Assert that a does not equal b. | |
#define | zassert_equal_ptr(a, b, ...) |
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(...) |
Assert that 2 memory buffers have the same contents. | |
#define | zassert_mem_equal__(buf, exp, size, ...) |
Internal assert that 2 memory buffers have the same contents. | |
#define | zassert_str_equal(s1, s2, ...) |
Assert that 2 strings have the same contents. | |
This module provides assertions when using Ztest.
#define zassert | ( | cond, | |
default_msg, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
#define zassert_between_inclusive | ( | a, | |
l, | |||
u, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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 | ( | ... | ) |
#include </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/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, | |
... ) |
#include </home/runner/work/zephyr/zephyr/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 | ( | ... | ) |
#include </home/runner/work/zephyr/zephyr/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 </home/runner/work/zephyr/zephyr/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, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
#define zexpect | ( | cond, | |
default_msg, | |||
... ) |
#include </home/runner/work/zephyr/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>