From 79519c4dbe8790004e3e3723fa69aee1348fa13a Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Tue, 17 Dec 2019 09:27:56 +0100 Subject: [PATCH] tests: unit: util: Add test for IF_ENABLED() Added test for new macro. Signed-off-by: Krzysztof Chruscinski --- tests/unit/util/main.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/unit/util/main.c b/tests/unit/util/main.c index 6363409fe10..03b58e1a81a 100644 --- a/tests/unit/util/main.c +++ b/tests/unit/util/main.c @@ -110,6 +110,25 @@ void test_COND_CODE_0(void) zassert_true((y3 == 1), NULL); } +void test_IF_ENABLED(void) +{ + #define test_IF_ENABLED_FLAG_A 1 + #define test_IF_ENABLED_FLAG_B 0 + + IF_ENABLED(test_IF_ENABLED_FLAG_A, (goto skipped;)) + /* location should be skipped if IF_ENABLED macro is correct. */ + zassert_false(true, "location should be skipped"); +skipped: + IF_ENABLED(test_IF_ENABLED_FLAG_B, (zassert_false(true, "");)) + + IF_ENABLED(test_IF_ENABLED_FLAG_C, (zassert_false(true, "");)) + + zassert_true(true, ""); + + #undef test_IF_ENABLED_FLAG_A + #undef test_IF_ENABLED_FLAG_B +} + void test_UTIL_LISTIFY(void) { int i = 0; @@ -157,6 +176,7 @@ void test_main(void) ztest_unit_test(test_u8_to_dec), ztest_unit_test(test_COND_CODE_1), ztest_unit_test(test_COND_CODE_0), + ztest_unit_test(test_IF_ENABLED), ztest_unit_test(test_UTIL_LISTIFY), ztest_unit_test(test_z_max_z_min) );