File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,38 @@ ZTEST(util, test_COND_CODE_0) {
165165 zassert_true ((y3 == 1 ));
166166}
167167
168+ ZTEST (util , test_COND_CASE_1 ) {
169+ /* Intentionally undefined symbols used to verify that only the selected
170+ * branch expands.
171+ */
172+ #define CASE_TRUE 1
173+ #define CASE_FALSE 0
174+
175+ int prioritized = COND_CASE_1 (
176+ CASE_TRUE , (42 ),
177+ CASE_TRUE , (COND_CASE_1_SHOULD_NOT_REACH_SECOND_TRUE_CASE ),
178+ (0 ));
179+ zexpect_equal (prioritized , 42 );
180+
181+ int selected = COND_CASE_1 (
182+ CASE_FALSE , (COND_CASE_1_SHOULD_NOT_USE_FIRST_CASE ),
183+ CASE_TRUE , (7 ),
184+ (11 ));
185+ zexpect_equal (selected , 7 );
186+
187+ int fallback = COND_CASE_1 (
188+ CASE_FALSE , (COND_CASE_1_SHOULD_NOT_USE_SECOND_CASE ),
189+ CASE_FALSE , (COND_CASE_1_SHOULD_NOT_USE_THIRD_CASE ),
190+ (5 ));
191+ zexpect_equal (fallback , 5 );
192+
193+ int only_default = COND_CASE_1 ((9 ));
194+ zexpect_equal (only_default , 9 );
195+
196+ #undef CASE_TRUE
197+ #undef CASE_FALSE
198+ }
199+
168200#undef ZERO
169201#undef SEVEN
170202#undef A_BUILD_ERROR
You can’t perform that action at this time.
0 commit comments