subsys/testsuite: use bool for condition types
Use of the test suite in C++ causes warnings because use of defined cast operators have the wrong target type. For example, many standard container APIs use operator bool() to test for empty containers. Code like zassert_true(v, "") fails to build when the test parameter is an int. Correct the argument type. This also causes any use of an assignment expression as a conditional in zassert to be diagnosed as a potential error. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
241044f178
commit
daed96802f
1 changed files with 5 additions and 4 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -26,9 +27,9 @@ extern "C" {
|
|||
void ztest_test_fail(void);
|
||||
#if CONFIG_ZTEST_ASSERT_VERBOSE == 0
|
||||
|
||||
static inline void z_zassert_(int cond, const char *file, int line)
|
||||
static inline void z_zassert_(bool cond, const char *file, int line)
|
||||
{
|
||||
if (!(cond)) {
|
||||
if (cond == false) {
|
||||
PRINT("\n Assertion failed at %s:%d\n",
|
||||
file, line);
|
||||
ztest_test_fail();
|
||||
|
@ -40,13 +41,13 @@ static inline void z_zassert_(int cond, const char *file, int line)
|
|||
|
||||
#else /* CONFIG_ZTEST_ASSERT_VERBOSE != 0 */
|
||||
|
||||
static inline void z_zassert(int cond,
|
||||
static inline void z_zassert(bool cond,
|
||||
const char *default_msg,
|
||||
const char *file,
|
||||
int line, const char *func,
|
||||
const char *msg, ...)
|
||||
{
|
||||
if (!(cond)) {
|
||||
if (cond == false) {
|
||||
va_list vargs;
|
||||
|
||||
va_start(vargs, msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue