Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
This module provides assumptions when using Ztest. More...
Macros | |
#define | zassume_true(cond, ...) zassume(cond, #cond " is false", ##__VA_ARGS__) |
Assume that cond is true. | |
#define | zassume_false(cond, ...) zassume(!(cond), #cond " is true", ##__VA_ARGS__) |
Assume that cond is false. | |
#define | zassume_ok(cond, ...) zassume(!(cond), #cond " is non-zero", ##__VA_ARGS__) |
Assume that cond is 0 (success) | |
#define | zassume_not_ok(cond, ...) zassume(!!(cond), #cond " is zero", ##__VA_ARGS__) |
Assume that cond is not 0 (failure) | |
#define | zassume_is_null(ptr, ...) zassume((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__) |
Assume that ptr is NULL. | |
#define | zassume_not_null(ptr, ...) zassume((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__) |
Assume that ptr is not NULL. | |
#define | zassume_equal(a, b, ...) zassume((a) == (b), #a " not equal to " #b, ##__VA_ARGS__) |
Assume that a equals b. | |
#define | zassume_not_equal(a, b, ...) zassume((a) != (b), #a " equal to " #b, ##__VA_ARGS__) |
Assume that a does not equal b. | |
#define | zassume_equal_ptr(a, b, ...) zassume((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__) |
Assume that a equals b. | |
#define | zassume_within(a, b, d, ...) |
Assume that a is within b with delta d. | |
#define | zassume_between_inclusive(a, l, u, ...) |
Assume that a is greater than or equal to l and less than or equal to u. | |
#define | zassume_mem_equal(...) zassume_mem_equal__(__VA_ARGS__) |
Assume that 2 memory buffers have the same contents. | |
#define | zassume_mem_equal__(buf, exp, size, ...) zassume(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__) |
Internal assume that 2 memory buffers have the same contents. | |
#define | zassume_str_equal(s1, s2, ...) zassume(strcmp(s1, s2) == 0, #s1 " not equal to " #s2, ##__VA_ARGS__) |
Assumes that 2 strings have the same contents. | |
This module provides assumptions when using Ztest.
#define zassume_between_inclusive | ( | a, | |
l, | |||
u, | |||
... | |||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that a is greater than or equal to l and less than or equal to u.
If the assumption fails, the test will be marked as "skipped".
a | Value to compare |
l | Lower limit |
u | Upper limit |
... | Optional message and variables to print if the assumption fails |
#define zassume_equal | ( | a, | |
b, | |||
... | |||
) | zassume((a) == (b), #a " not equal to " #b, ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that a equals b.
a and b won't be converted and will be compared directly. If the assumption fails, the test will be marked as "skipped".
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assumption fails |
#define zassume_equal_ptr | ( | a, | |
b, | |||
... | |||
) | zassume((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that a equals b.
a and b will be converted to void *
before comparing. If the assumption fails, the test will be marked as "skipped".
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assumption fails |
#define zassume_false | ( | cond, | |
... | |||
) | zassume(!(cond), #cond " is true", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that cond is false.
If the assumption fails, the test will be marked as "skipped".
cond | Condition to check |
... | Optional message and variables to print if the assumption fails |
#define zassume_is_null | ( | ptr, | |
... | |||
) | zassume((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that ptr is NULL.
If the assumption fails, the test will be marked as "skipped".
ptr | Pointer to compare |
... | Optional message and variables to print if the assumption fails |
#define zassume_mem_equal | ( | ... | ) | zassume_mem_equal__(__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that 2 memory buffers have the same contents.
This macro calls the final memory comparison assumption 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 zassume_mem_equal__ for real arguments accepted. |
#define zassume_mem_equal__ | ( | buf, | |
exp, | |||
size, | |||
... | |||
) | zassume(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Internal assume that 2 memory buffers have the same contents.
If the assumption fails, the test will be marked as "skipped".
buf | Buffer to compare |
exp | Buffer with expected contents |
size | Size of buffers |
... | Optional message and variables to print if the assumption fails |
#define zassume_not_equal | ( | a, | |
b, | |||
... | |||
) | zassume((a) != (b), #a " equal to " #b, ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that a does not equal b.
a and b won't be converted and will be compared directly. If the assumption fails, the test will be marked as "skipped".
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the assumption fails |
#define zassume_not_null | ( | ptr, | |
... | |||
) | zassume((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that ptr is not NULL.
If the assumption fails, the test will be marked as "skipped".
ptr | Pointer to compare |
... | Optional message and variables to print if the assumption fails |
#define zassume_not_ok | ( | cond, | |
... | |||
) | zassume(!!(cond), #cond " is zero", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that cond is not 0 (failure)
If the assumption fails, the test will be marked as "skipped".
cond | Condition to check |
... | Optional message and variables to print if the assumption fails |
#define zassume_ok | ( | cond, | |
... | |||
) | zassume(!(cond), #cond " is non-zero", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that cond is 0 (success)
If the assumption fails, the test will be marked as "skipped".
cond | Condition to check |
... | Optional message and variables to print if the assumption fails |
#define zassume_str_equal | ( | s1, | |
s2, | |||
... | |||
) | zassume(strcmp(s1, s2) == 0, #s1 " not equal to " #s2, ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assumes 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 zassume_true | ( | cond, | |
... | |||
) | zassume(cond, #cond " is false", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that cond is true.
If the assumption fails, the test will be marked as "skipped".
cond | Condition to check |
... | Optional message and variables to print if the assumption fails |
#define zassume_within | ( | a, | |
b, | |||
d, | |||
... | |||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Assume that a is within b with delta d.
If the assumption fails, the test will be marked as "skipped".
a | Value to compare |
b | Value to compare |
d | Delta |
... | Optional message and variables to print if the assumption fails |