Skip to content

Commit 2089193

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 7250903 commit 2089193

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
@@ -461,6 +461,28 @@ ZTEST(util, test_GET_ARGS_LESS_N) {
461461
zassert_equal(c[0], 3);
462462
}
463463

464+
ZTEST(util, test_GET_ARGS_FIRST_N)
465+
{
466+
uint8_t a[] = {GET_ARGS_FIRST_N(0, 1, 2, 3)};
467+
uint8_t b[] = {GET_ARGS_FIRST_N(1, 1, 2, 3)};
468+
uint8_t c[] = {GET_ARGS_FIRST_N(2, 1, 2, 3)};
469+
uint8_t d[] = {GET_ARGS_FIRST_N(3, 1, 2, 3)};
470+
471+
zassert_equal(sizeof(a), 0);
472+
473+
zassert_equal(sizeof(b), 1);
474+
zassert_equal(b[0], 1);
475+
476+
zassert_equal(sizeof(c), 2);
477+
zassert_equal(c[0], 1);
478+
zassert_equal(c[1], 2);
479+
480+
zassert_equal(sizeof(d), 3);
481+
zassert_equal(d[0], 1);
482+
zassert_equal(d[1], 2);
483+
zassert_equal(d[2], 3);
484+
}
485+
464486
ZTEST(util, test_mixing_GET_ARG_and_FOR_EACH) {
465487
#undef TEST_MACRO
466488
#define TEST_MACRO(x) x,

0 commit comments

Comments
 (0)