From 3daa09cd58192962e9bf3693e55bdb7b0155773c Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 11 Feb 2019 11:24:52 +0200 Subject: [PATCH 1/2] tests: util: Correct test name Trivial syntax fix. Signed-off-by: Andrei Emeltchenko --- tests/misc/util/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/misc/util/src/main.c b/tests/misc/util/src/main.c index 9a07953536fad..ab8180fbbe8ae 100644 --- a/tests/misc/util/src/main.c +++ b/tests/misc/util/src/main.c @@ -59,9 +59,9 @@ void test_COND_CODE_0(void) /*test case main entry*/ void test_main(void) { - ztest_test_suite(test_ringbuffer_api, + ztest_test_suite(test_util_api, ztest_unit_test(test_COND_CODE_1), ztest_unit_test(test_COND_CODE_0) ); - ztest_run_test_suite(test_ringbuffer_api); + ztest_run_test_suite(test_util_api); } From 0ca9590d75e15a1ec5b0c6df8ce07dbfb186b86e Mon Sep 17 00:00:00 2001 From: Andrei Emeltchenko Date: Mon, 11 Feb 2019 11:28:56 +0200 Subject: [PATCH 2/2] tests: util: Add UTIL_LISTIFY tests Add tests for UTIL_LISTIFY macro. Signed-off-by: Andrei Emeltchenko --- tests/misc/util/src/main.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/misc/util/src/main.c b/tests/misc/util/src/main.c index ab8180fbbe8ae..7d55e3bc4fd3b 100644 --- a/tests/misc/util/src/main.c +++ b/tests/misc/util/src/main.c @@ -56,12 +56,33 @@ void test_COND_CODE_0(void) zassert_true((y3 == 1), NULL); } +void test_UTIL_LISTIFY(void) +{ + int i = 0; + +#define INC(x, _) \ + do { \ + i += x; \ + } while (0); + +#define DEFINE(x, _) int a##x; +#define MARK_UNUSED(x, _) ARG_UNUSED(a##x); + + UTIL_LISTIFY(4, DEFINE, _) + UTIL_LISTIFY(4, MARK_UNUSED, _) + + UTIL_LISTIFY(4, INC, _) + + zassert_equal(i, 0 + 1 + 2 + 3, NULL); +} + /*test case main entry*/ void test_main(void) { ztest_test_suite(test_util_api, ztest_unit_test(test_COND_CODE_1), - ztest_unit_test(test_COND_CODE_0) + ztest_unit_test(test_COND_CODE_0), + ztest_unit_test(test_UTIL_LISTIFY) ); ztest_run_test_suite(test_util_api); }