ztest: Add comfort functions for non-zero return codes
Many functions return non-zero return codes on errors. I added an assert
for the case, when a function is expected to fail. It is just a
shorthand for `zassert_not_equal(0, ret);`, analogous to
`zassert_ok`, introduced in c5d85e175f
.
I also added the corresponding `zassume_nok` and `zexpect_nok`.
Signed-off-by: Greter Raffael <rgreter@baumer.com>
This commit is contained in:
parent
e466b7ac26
commit
774858c6dc
3 changed files with 38 additions and 0 deletions
|
@ -20,6 +20,7 @@ ZTEST(framework_tests, test_assert_tests)
|
|||
zassert_not_null("foo", NULL);
|
||||
zassert_equal(1, 1);
|
||||
zassert_equal_ptr(NULL, NULL, NULL);
|
||||
zassert_not_ok(-EIO);
|
||||
}
|
||||
|
||||
ZTEST(framework_tests, test_assert_mem_equal)
|
||||
|
|
|
@ -59,6 +59,17 @@ ZTEST(expect, test_fail_expect_ok)
|
|||
zexpect_ok(5);
|
||||
}
|
||||
|
||||
ZTEST(expect, test_expect_not_ok)
|
||||
{
|
||||
zexpect_not_ok(-EIO);
|
||||
}
|
||||
|
||||
ZTEST_EXPECT_FAIL(expect, test_fail_expect_not_ok);
|
||||
ZTEST(expect, test_fail_expect_not_ok)
|
||||
{
|
||||
zexpect_not_ok(0);
|
||||
}
|
||||
|
||||
ZTEST(expect, test_expect_is_null)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue