Skip to content

Commit a4e950a

Browse files
finikorgnashif
authored andcommitted
tests: util: Add UTIL_LISTIFY tests
Add tests for UTIL_LISTIFY macro. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent a3ea6a5 commit a4e950a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/misc/util/src/main.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,33 @@ void test_COND_CODE_0(void)
5656
zassert_true((y3 == 1), NULL);
5757
}
5858

59+
void test_UTIL_LISTIFY(void)
60+
{
61+
int i = 0;
62+
63+
#define INC(x, _) \
64+
do { \
65+
i += x; \
66+
} while (0);
67+
68+
#define DEFINE(x, _) int a##x;
69+
#define MARK_UNUSED(x, _) ARG_UNUSED(a##x);
70+
71+
UTIL_LISTIFY(4, DEFINE, _)
72+
UTIL_LISTIFY(4, MARK_UNUSED, _)
73+
74+
UTIL_LISTIFY(4, INC, _)
75+
76+
zassert_equal(i, 0 + 1 + 2 + 3, NULL);
77+
}
78+
5979
/*test case main entry*/
6080
void test_main(void)
6181
{
6282
ztest_test_suite(test_util_api,
6383
ztest_unit_test(test_COND_CODE_1),
64-
ztest_unit_test(test_COND_CODE_0)
84+
ztest_unit_test(test_COND_CODE_0),
85+
ztest_unit_test(test_UTIL_LISTIFY)
6586
);
6687
ztest_run_test_suite(test_util_api);
6788
}

0 commit comments

Comments
 (0)