Zephyr Project API  3.3.0
A Scalable Open Source RTOS
ztest_assert.h File Reference

Zephyr testing framework assertion macros. More...

#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <zephyr/ztest.h>

Go to the source code of this file.

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 zassert_unreachable(...)   zassert(0, "Reached unreachable code", ##__VA_ARGS__)
 Assert that this function call won't be reached. More...
 
#define zassert_true(cond, ...)   zassert(cond, #cond " is false", ##__VA_ARGS__)
 Assert that cond is true. More...
 
#define zassert_false(cond, ...)   zassert(!(cond), #cond " is true", ##__VA_ARGS__)
 Assert that cond is false. More...
 
#define zassert_ok(cond, ...)   zassert(!(cond), #cond " is non-zero", ##__VA_ARGS__)
 Assert that cond is 0 (success) More...
 
#define zassert_is_null(ptr, ...)   zassert((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__)
 Assert that ptr is NULL. More...
 
#define zassert_not_null(ptr, ...)   zassert((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__)
 Assert that ptr is not NULL. More...
 
#define zassert_equal(a, b, ...)   zassert((a) == (b), #a " not equal to " #b, ##__VA_ARGS__)
 Assert that a equals b. More...
 
#define zassert_not_equal(a, b, ...)   zassert((a) != (b), #a " equal to " #b, ##__VA_ARGS__)
 Assert that a does not equal b. More...
 
#define zassert_equal_ptr(a, b, ...)    zassert((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__)
 Assert that a equals b. More...
 
#define zassert_within(a, b, d, ...)
 Assert that a is within b with delta d. More...
 
#define zassert_between_inclusive(a, l, u, ...)
 Assert that a is greater than or equal to l and less than or equal to u. 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, ...)    zassert(memcmp(buf, exp, size) == 0, #buf " not equal to " #exp, ##__VA_ARGS__)
 Internal assert that 2 memory buffers have the same contents. More...
 
#define zassume_true(cond, ...)   zassume(cond, #cond " is false", ##__VA_ARGS__)
 Assume that cond is true. More...
 
#define zassume_false(cond, ...)   zassume(!(cond), #cond " is true", ##__VA_ARGS__)
 Assume that cond is false. More...
 
#define zassume_ok(cond, ...)   zassume(!(cond), #cond " is non-zero", ##__VA_ARGS__)
 Assume that cond is 0 (success) More...
 
#define zassume_is_null(ptr, ...)   zassume((ptr) == NULL, #ptr " is not NULL", ##__VA_ARGS__)
 Assume that ptr is NULL. More...
 
#define zassume_not_null(ptr, ...)   zassume((ptr) != NULL, #ptr " is NULL", ##__VA_ARGS__)
 Assume that ptr is not NULL. More...
 
#define zassume_equal(a, b, ...)   zassume((a) == (b), #a " not equal to " #b, ##__VA_ARGS__)
 Assume that a equals b. More...
 
#define zassume_not_equal(a, b, ...)   zassume((a) != (b), #a " equal to " #b, ##__VA_ARGS__)
 Assume that a does not equal b. More...
 
#define zassume_equal_ptr(a, b, ...)    zassume((void *)(a) == (void *)(b), #a " not equal to " #b, ##__VA_ARGS__)
 Assume that a equals b. More...
 
#define zassume_within(a, b, d, ...)
 Assume that a is within b with delta d. More...
 
#define zassume_between_inclusive(a, l, u, ...)
 Assume that a is greater than or equal to l and less than or equal to u. More...
 
#define zassume_mem_equal(...)   zassume_mem_equal__(__VA_ARGS__)
 Assume that 2 memory buffers have the same contents. More...
 
#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. More...
 

Functions

const char * ztest_relative_filename (const char *file)
 
void ztest_test_fail (void)
 
void ztest_test_skip (void)
 
void ztest_skip_failed_assumption (void)
 

Detailed Description

Zephyr testing framework assertion macros.

Function Documentation

◆ ztest_relative_filename()

const char * ztest_relative_filename ( const char *  file)

◆ ztest_skip_failed_assumption()

void ztest_skip_failed_assumption ( void  )

◆ ztest_test_fail()

void ztest_test_fail ( void  )

◆ ztest_test_skip()

void ztest_test_skip ( void  )