Skip to content

Commit

Permalink
tests: unit: util: Add test for GET_ARGS_FIRST_N
Browse files Browse the repository at this point in the history
Add `GET_ARGS_FIRST_N` tests.

Signed-off-by: TOKITA Hiroshi <[email protected]>
  • Loading branch information
soburi committed Jan 19, 2025
1 parent 8918c76 commit eb9b927
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/unit/util/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,28 @@ ZTEST(util, test_GET_ARGS_LESS_N) {
zassert_equal(c[0], 3);
}

ZTEST(util, test_GET_ARGS_FIRST_N) {
uint8_t a[] = { GET_ARGS_FIRST_N(0, 1, 2, 3) };
uint8_t b[] = { GET_ARGS_FIRST_N(1, 1, 2, 3) };
uint8_t c[] = { GET_ARGS_FIRST_N(2, 1, 2, 3) };
uint8_t d[] = { GET_ARGS_FIRST_N(3, 1, 2, 3) };

zassert_equal(sizeof(a), 0);

zassert_equal(sizeof(b), 1);
zassert_equal(b[0], 1);


zassert_equal(sizeof(c), 2);
zassert_equal(c[0], 1);
zassert_equal(c[1], 2);

zassert_equal(sizeof(d), 3);
zassert_equal(d[0], 1);
zassert_equal(d[1], 2);
zassert_equal(d[2], 3);
}

ZTEST(util, test_mixing_GET_ARG_and_FOR_EACH) {
#undef TEST_MACRO
#define TEST_MACRO(x) x,
Expand Down

0 comments on commit eb9b927

Please sign in to comment.