1 /*
2  * Copyright (c) 2024 TOKITA Hiroshi
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <string.h>
8 #include <zephyr/kernel.h>
9 #include <zephyr/sys/__assert.h>
10 #include <zephyr/ztest.h>
11 
ZTEST(test_kconfig_functions,test_arithmetic)12 ZTEST(test_kconfig_functions, test_arithmetic)
13 {
14 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_ADD_10, 10);
15 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_ADD_10_3, 10 + 3);
16 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_ADD_10_3_2, 10 + 3 + 2);
17 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_SUB_10, 10);
18 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_SUB_10_3, 10 - 3);
19 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_SUB_10_3_2, 10 - 3 - 2);
20 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MUL_10, 10);
21 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MUL_10_3, 10 * 3);
22 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MUL_10_3_2, 10 * 3 * 2);
23 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_DIV_10, 10);
24 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_DIV_10_3, 10 / 3);
25 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_DIV_10_3_2, 10 / 3 / 2);
26 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MOD_10, 10);
27 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MOD_10_3, 10 % 3);
28 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_MOD_10_3_2, 10 % 3 % 2);
29 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_INC_1, 1 + 1);
30 	zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_INC_1_1, "2,2");
31 	zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_INC_INC_1_1, "3,3");
32 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_1, 1 - 1);
33 	zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_1_1, "0,0");
34 	zassert_str_equal(CONFIG_KCONFIG_ARITHMETIC_DEC_DEC_1_1, "-1,-1");
35 	zassert_equal(CONFIG_KCONFIG_ARITHMETIC_ADD_INC_1_1, (1 + 1) + (1 + 1));
36 }
37 
ZTEST(test_kconfig_functions,test_min_max)38 ZTEST(test_kconfig_functions, test_min_max)
39 {
40 	zassert_equal(CONFIG_KCONFIG_MIN_10, 10);
41 	zassert_equal(CONFIG_KCONFIG_MIN_10_3, MIN(10, 3));
42 	zassert_equal(CONFIG_KCONFIG_MIN_10_3_2, MIN(MIN(10, 3), 2));
43 	zassert_equal(CONFIG_KCONFIG_MAX_10, 10);
44 	zassert_equal(CONFIG_KCONFIG_MAX_10_3, MAX(10, 3));
45 	zassert_equal(CONFIG_KCONFIG_MAX_10_3_2, MAX(MAX(10, 3), 2));
46 }
47 
48 ZTEST_SUITE(test_kconfig_functions, NULL, NULL, NULL, NULL, NULL);
49