From 04edca7a9f70b000dbb9345ef49d5aa7f0d692bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Tue, 21 Nov 2023 12:27:32 +0100 Subject: [PATCH] tests: unit: util: Add test for CONCAT macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test for CONCAT. Signed-off-by: Krzysztof Chruściński --- tests/unit/util/main.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/unit/util/main.c b/tests/unit/util/main.c index fc8af19d34a..4486d89272a 100644 --- a/tests/unit/util/main.c +++ b/tests/unit/util/main.c @@ -717,4 +717,40 @@ ZTEST(util, test_mem_xor_128) zassert_mem_equal(expected_result, dst, 16); } +ZTEST(util, test_CONCAT) +{ +#define _CAT_PART1 1 +#define CAT_PART1 _CAT_PART1 +#define _CAT_PART2 2 +#define CAT_PART2 _CAT_PART2 +#define _CAT_PART3 3 +#define CAT_PART3 _CAT_PART3 +#define _CAT_PART4 4 +#define CAT_PART4 _CAT_PART4 +#define _CAT_PART5 5 +#define CAT_PART5 _CAT_PART5 +#define _CAT_PART6 6 +#define CAT_PART6 _CAT_PART6 +#define _CAT_PART7 7 +#define CAT_PART7 _CAT_PART7 +#define _CAT_PART8 8 +#define CAT_PART8 _CAT_PART8 + + zassert_equal(CONCAT(CAT_PART1), 1); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2), 12); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3), 123); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3, CAT_PART4), 1234); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3, CAT_PART4, CAT_PART5), 12345); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3, CAT_PART4, CAT_PART5, CAT_PART6), + 123456); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3, CAT_PART4, + CAT_PART5, CAT_PART6, CAT_PART7), + 1234567); + zassert_equal(CONCAT(CAT_PART1, CAT_PART2, CAT_PART3, CAT_PART4, + CAT_PART5, CAT_PART6, CAT_PART7, CAT_PART8), + 12345678); + + zassert_equal(CONCAT(CAT_PART1, CONCAT(CAT_PART2, CAT_PART3)), 123); +} + ZTEST_SUITE(util, NULL, NULL, NULL, NULL, NULL);