Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
|
Macros | |
#define | zassert(cond, default_msg, msg, ...) |
Fail the test, if cond is false. More... | |
#define | zassert_unreachable(msg, ...) |
Assert that this function call won't be reached. More... | |
#define | zassert_true(cond, msg, ...) |
Assert that cond is true. More... | |
#define | zassert_false(cond, msg, ...) |
Assert that cond is false. More... | |
#define | zassert_ok(cond, msg, ...) |
Assert that cond is 0 (success) More... | |
#define | zassert_is_null(ptr, msg, ...) |
Assert that ptr is NULL. More... | |
#define | zassert_not_null(ptr, msg, ...) |
Assert that ptr is not NULL. More... | |
#define | zassert_equal(a, b, msg, ...) |
Assert that a equals b. More... | |
#define | zassert_not_equal(a, b, msg, ...) |
Assert that a does not equal b. More... | |
#define | zassert_equal_ptr(a, b, msg, ...) |
Assert that a equals b. More... | |
#define | zassert_within(a, b, d, msg, ...) |
Assert that a is within b with delta d. More... | |
#define | zassert_mem_equal(...) zassert_mem_equal__(__VA_ARGS__) |
Assert that 2 memory buffers have the same contents. More... | |
#define | zassert_mem_equal__(buf, exp, size, msg, ...) |
Internal assert that 2 memory buffers have the same contents. More... | |
This module provides assertions when using Ztest.
#define zassert | ( | cond, | |
default_msg, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Fail the test, if cond is false.
You probably don't need to call this macro directly. You should instead use zassert_{condition} macros below.
Note that when CONFIG_MULTITHREADING=n macro returns from the function. It is then expected that in that case ztest asserts will be used only in the context of the test function.
cond | Condition to check |
msg | Optional, can be NULL. Message to print if cond is false. |
default_msg | Message to print if cond is false |
#define zassert_equal | ( | a, | |
b, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/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 |
msg | Optional message to print if the assertion fails |
#define zassert_equal_ptr | ( | a, | |
b, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/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 |
msg | Optional message to print if the assertion fails |
#define zassert_false | ( | cond, | |
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that cond is false.
cond | Condition to check |
msg | Optional message to print if the assertion fails |
#define zassert_is_null | ( | ptr, | |
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that ptr is NULL.
ptr | Pointer to compare |
msg | Optional message to print if the assertion fails |
#define zassert_mem_equal | ( | ... | ) | zassert_mem_equal__(__VA_ARGS__) |
#include <subsys/testsuite/ztest/include/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, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/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 |
msg | Optional message to print if the assertion fails |
#define zassert_not_equal | ( | a, | |
b, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/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 |
msg | Optional message to print if the assertion fails |
#define zassert_not_null | ( | ptr, | |
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that ptr is not NULL.
ptr | Pointer to compare |
msg | Optional message to print if the assertion fails |
#define zassert_ok | ( | cond, | |
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that cond is 0 (success)
cond | Condition to check |
msg | Optional message to print if the assertion fails |
#define zassert_true | ( | cond, | |
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that cond is true.
cond | Condition to check |
msg | Optional message to print if the assertion fails |
#define zassert_unreachable | ( | msg, | |
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that this function call won't be reached.
msg | Optional message to print if the assertion fails |
#define zassert_within | ( | a, | |
b, | |||
d, | |||
msg, | |||
... | |||
) |
#include <subsys/testsuite/ztest/include/ztest_assert.h>
Assert that a is within b with delta d.
a | Value to compare |
b | Value to compare |
d | Delta |
msg | Optional message to print if the assertion fails |