Commit Graph

14 Commits

Author SHA1 Message Date
Peter Bigot 95d32549e7 tests/unit/util: refactor to test in both C and C++ language environments
Move all the tests into an include file that is included once from the
main C-compiled module, and again from a linked in C++-compiled
module.  The C compile invokes both test suites.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-08-12 16:39:37 -05:00
Krzysztof Chruscinski 4baf24203d tests: unit: util: Add tests for new macros
Added tests for GET_ARG_N and GET_ARGS_LESS_N

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-22 15:18:07 +02:00
Krzysztof Chruscinski 727f8e0889 tests: unit: util: Add test for nested FOR_EACH call
Added test for case were FOR_EACH call is nested.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Krzysztof Chruscinski 1b4b9386e5 sys: util: Added separator to FOR_EACH_ macros
Added separator (e.g. comma or semicolon) parameter to FOR_EACH_ family.
Separator is added between macro execution for each argument and not at
the end.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-06-10 11:58:13 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Dominik Ermel 6ba69f19d4 sys/util.h: Add IS_EMPTY and LIST_DROP_EMPTY macros
IS_EMPTY macro allows to check if defined name is empty, i.e.
does not contain replacement list.
LIST_DROP_EMPTY macro may be used to process __VA_ARGS__ type lists,
e.g. a,b,,c , and remove empty elements.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-05-08 17:50:25 +02:00
Krzysztof Chruscinski 8fcabf6032 tests: unit: util: Add test for FOR_EACH_FIXED_ARG macro
Added test for FOR_EACH_FIXED_ARG macro.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-06 14:30:18 +02:00
Krzysztof Chruscinski 8ab4a60471 tests: unit: util: Add tests for FOR_EACH and FOR_EACH_IDX macros
Extended suite to test macros.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2020-05-06 14:30:18 +02:00
Martí Bolívar 1edc84f526 sys/util.h: add UTIL_OR and UTIL_AND
These are short-circuiting utility helpers that can save typing
in situations where avoiding evaluation of the not-taken branch
skips invalid expressions.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-25 13:21:28 +01:00
Martí Bolívar 3c7a939743 tests: add util.h MACRO_MAP_CAT test
This wasn't tested when it was first added.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-03-25 13:21:28 +01:00
Kumar Gala 28a88fc638 sys/util.h: allow UTIL_LISTIFY to pass args to repeat macro
Change UTIL_LISTIFY to support passing arguments to the F macro.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-13 07:33:57 -06:00
Krzysztof Chruscinski 79519c4dbe tests: unit: util: Add test for IF_ENABLED()
Added test for new macro.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2019-12-18 08:14:52 -05:00
Anas Nashif 2051ad1846 tests: convert util test to a unit test
Merge tests/misc/util with existing util unit test.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-30 07:09:42 -04:00
Anas Nashif 50d5e37b8a tests: move util test to be unit tests
Move to a unit test, no need to build this for every platform we have.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-09-27 15:23:26 -04:00