Skip to content

Commit 1c6134a

Browse files
committed
tests: unit: util: Add test for GET_ARGS_FIRST_N
Add `GET_ARGS_FIRST_N` tests. Signed-off-by: TOKITA Hiroshi <[email protected]>
1 parent e09c8fb commit 1c6134a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/unit/util/main.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,28 @@ ZTEST(util, test_GET_ARGS_LESS_N) {
527527
zassert_equal(c[0], 3);
528528
}
529529

530+
ZTEST(util, test_GET_ARGS_FIRST_N)
531+
{
532+
uint8_t a[] = {GET_ARGS_FIRST_N(0, 1, 2, 3)};
533+
uint8_t b[] = {GET_ARGS_FIRST_N(1, 1, 2, 3)};
534+
uint8_t c[] = {GET_ARGS_FIRST_N(2, 1, 2, 3)};
535+
uint8_t d[] = {GET_ARGS_FIRST_N(3, 1, 2, 3)};
536+
537+
zassert_equal(sizeof(a), 0);
538+
539+
zassert_equal(sizeof(b), 1);
540+
zassert_equal(b[0], 1);
541+
542+
zassert_equal(sizeof(c), 2);
543+
zassert_equal(c[0], 1);
544+
zassert_equal(c[1], 2);
545+
546+
zassert_equal(sizeof(d), 3);
547+
zassert_equal(d[0], 1);
548+
zassert_equal(d[1], 2);
549+
zassert_equal(d[2], 3);
550+
}
551+
530552
ZTEST(util, test_mixing_GET_ARG_and_FOR_EACH) {
531553
#undef TEST_MACRO
532554
#define TEST_MACRO(x) x,

0 commit comments

Comments
 (0)