tests: unit: util: Add tests for IF_DISABLED
Add a testcase for the IF_DISABLED macro. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
parent
b4cd9c462a
commit
cc920696ed
2 changed files with 30 additions and 0 deletions
|
@ -38,6 +38,10 @@ ZTEST(util_cxx, test_IF_ENABLED) {
|
||||||
run_IF_ENABLED();
|
run_IF_ENABLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZTEST(util_cxx, test_IF_DISABLED) {
|
||||||
|
run_IF_DISABLED();
|
||||||
|
}
|
||||||
|
|
||||||
ZTEST(util_cxx, test_LISTIFY) {
|
ZTEST(util_cxx, test_LISTIFY) {
|
||||||
run_LISTIFY();
|
run_LISTIFY();
|
||||||
}
|
}
|
||||||
|
@ -186,6 +190,10 @@ ZTEST(util_cc, test_IF_ENABLED) {
|
||||||
run_IF_ENABLED();
|
run_IF_ENABLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZTEST(util_cc, test_IF_DISABLED) {
|
||||||
|
run_IF_DISABLED();
|
||||||
|
}
|
||||||
|
|
||||||
ZTEST(util_cc, test_LISTIFY) {
|
ZTEST(util_cc, test_LISTIFY) {
|
||||||
run_LISTIFY();
|
run_LISTIFY();
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,28 @@ skipped:
|
||||||
#undef test_IF_ENABLED_FLAG_B
|
#undef test_IF_ENABLED_FLAG_B
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void run_IF_DISABLED(void)
|
||||||
|
{
|
||||||
|
#define test_IF_DISABLED_FLAG_A 0
|
||||||
|
#define test_IF_DISABLED_FLAG_B 1
|
||||||
|
|
||||||
|
IF_DISABLED(test_IF_DISABLED_FLAG_A, (goto skipped_a;))
|
||||||
|
/* location should be skipped if IF_DISABLED macro is correct. */
|
||||||
|
zassert_false(true, "location A should be skipped");
|
||||||
|
skipped_a:
|
||||||
|
IF_DISABLED(test_IF_DISABLED_FLAG_B, (zassert_false(true, "");))
|
||||||
|
|
||||||
|
IF_DISABLED(test_IF_DISABLED_FLAG_C, (goto skipped_c;))
|
||||||
|
/* location should be skipped if IF_DISABLED macro is correct. */
|
||||||
|
zassert_false(true, "location C should be skipped");
|
||||||
|
skipped_c:
|
||||||
|
|
||||||
|
zassert_true(true, "");
|
||||||
|
|
||||||
|
#undef test_IF_DISABLED_FLAG_A
|
||||||
|
#undef test_IF_DISABLED_FLAG_B
|
||||||
|
}
|
||||||
|
|
||||||
void run_LISTIFY(void)
|
void run_LISTIFY(void)
|
||||||
{
|
{
|
||||||
int ab0 = 1;
|
int ab0 = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue