Zephyr API Documentation
3.6.99
A Scalable Open Source RTOS
|
This module provides expectations when using Ztest. More...
Macros | |
#define | zexpect_true(cond, ...) zexpect(cond, #cond " is false", ##__VA_ARGS__) |
Expect that cond is true, otherwise mark test as failed but continue its execution. | |
#define | zexpect_false(cond, ...) zexpect(!(cond), #cond " is true", ##__VA_ARGS__) |
Expect that cond is false, otherwise mark test as failed but continue its execution. | |
#define | zexpect_ok(cond, ...) zexpect(!(cond), #cond " is non-zero", ##__VA_ARGS__) |
Expect that cond is 0 (success), otherwise mark test as failed but continue its execution. | |
#define | zexpect_not_ok(cond, ...) zexpect(!!(cond), #cond " is zero", ##__VA_ARGS__) |
Expect that cond is not 0 (failure), otherwise mark test as failed but continue its execution. | |
#define | zexpect_is_null(ptr, ...) zexpect((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__) |
Expect that ptr is NULL, otherwise mark test as failed but continue its execution. | |
#define | zexpect_not_null(ptr, ...) zexpect((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__) |
Expect that ptr is not NULL, otherwise mark test as failed but continue its execution. | |
#define | zexpect_equal(a, b, ...) zexpect((a) == (b), #a " not equal to " #b, ##__VA_ARGS__) |
Expect that a equals b, otherwise mark test as failed but continue its execution. | |
#define | zexpect_not_equal(a, b, ...) zexpect((a) != (b), #a " equal to " #b, ##__VA_ARGS__) |
Expect that a does not equal b, otherwise mark test as failed but continue its execution. | |
#define | zexpect_equal_ptr(a, b, ...) zexpect((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__) |
Expect that a equals b, otherwise mark test as failed but continue its execution. | |
#define | zexpect_within(a, b, delta, ...) |
Expect that a is within b with delta d, otherwise mark test as failed but continue its execution. | |
#define | zexpect_between_inclusive(a, lower, upper, ...) |
Expect that a is greater than or equal to l and less than or equal to u, otherwise mark test as failed but continue its execution. | |
#define | zexpect_mem_equal(buf, exp, size, ...) zexpect(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__) |
Expect that 2 memory buffers have the same contents, otherwise mark test as failed but continue its execution. | |
This module provides expectations when using Ztest.
#define zexpect_between_inclusive | ( | a, | |
lower, | |||
upper, | |||
... | |||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Expect that a is greater than or equal to l and less than or equal to u, otherwise mark test as failed but continue its execution.
a | Value to compare |
lower | Lower limit |
upper | Upper limit |
... | Optional message and variables to print if the expectation fails |
#define zexpect_equal | ( | a, | |
b, | |||
... | |||
) | zexpect((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>
Expect that a equals b, otherwise mark test as failed but continue its execution.
a | Value to compare |
b | Value to compare |
... | Optional message and variables to print if the expectation fails |
#define zexpect_equal_ptr | ( | a, | |
b, | |||
... | |||
) | zexpect((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>
Expect that a equals b, otherwise mark test as failed but continue its execution.
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 expectation fails |
#define zexpect_false | ( | cond, | |
... | |||
) | zexpect(!(cond), #cond " is true", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Expect that cond is false, otherwise mark test as failed but continue its execution.
cond | Condition to check |
... | Optional message and variables to print if the expectation fails |
#define zexpect_is_null | ( | ptr, | |
... | |||
) | zexpect((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>
Expect that ptr is NULL, otherwise mark test as failed but continue its execution.
ptr | Pointer to compare |
... | Optional message and variables to print if the expectation fails |
#define zexpect_mem_equal | ( | buf, | |
exp, | |||
size, | |||
... | |||
) | zexpect(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>
Expect that 2 memory buffers have the same contents, otherwise mark test as failed but continue its execution.
buf | Buffer to compare |
exp | Buffer with expected contents |
size | Size of buffers |
... | Optional message and variables to print if the expectation fails |
#define zexpect_not_equal | ( | a, | |
b, | |||
... | |||
) | zexpect((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>
Expect that a does not equal b, otherwise mark test as failed but continue its execution.
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 expectation fails |
#define zexpect_not_null | ( | ptr, | |
... | |||
) | zexpect((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>
Expect that ptr is not NULL, otherwise mark test as failed but continue its execution.
ptr | Pointer to compare |
... | Optional message and variables to print if the expectation fails |
#define zexpect_not_ok | ( | cond, | |
... | |||
) | zexpect(!!(cond), #cond " is zero", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Expect that cond is not 0 (failure), otherwise mark test as failed but continue its execution.
cond | Condition to check |
... | Optional message and variables to print if the expectation fails |
#define zexpect_ok | ( | cond, | |
... | |||
) | zexpect(!(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>
Expect that cond is 0 (success), otherwise mark test as failed but continue its execution.
cond | Condition to check |
... | Optional message and variables to print if the expectation fails |
#define zexpect_true | ( | cond, | |
... | |||
) | zexpect(cond, #cond " is false", ##__VA_ARGS__) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Expect that cond is true, otherwise mark test as failed but continue its execution.
cond | Condition to check |
... | Optional message and variables to print if the expectation fails |
#define zexpect_within | ( | a, | |
b, | |||
delta, | |||
... | |||
) |
#include </home/runner/work/sdk-nrf/sdk-nrf/ncs/zephyr/subsys/testsuite/ztest/include/zephyr/ztest_assert.h>
Expect that a is within b with delta d, otherwise mark test as failed but continue its execution.
a | Value to compare |
b | Value to compare |
delta | Difference between a and b |
... | Optional message and variables to print if the expectation fails |