Lines Matching +full:- +full:r

3  * SPDX-License-Identifier: Apache-2.0
10 * +-----+-----+
12 * +-----+-----+
13 * | -10 | 0 |
14 * | -5 | 1 |
15 * +-----+-----+
18 * +-----+-----+
26 * +-----+-----+
29 * +-----+-----+
31 static const struct linear_range r[] = { variable
32 LINEAR_RANGE_INIT(-10, 5U, 0U, 1U),
38 static const size_t r_cnt = ARRAY_SIZE(r);
42 zassert_equal(r[0].min, -10); in ZTEST()
43 zassert_equal(r[0].step, 5U); in ZTEST()
44 zassert_equal(r[0].min_idx, 0U); in ZTEST()
45 zassert_equal(r[0].max_idx, 1U); in ZTEST()
50 zassert_equal(linear_range_values_count(&r[0]), 2U); in ZTEST()
51 zassert_equal(linear_range_values_count(&r[1]), 2U); in ZTEST()
52 zassert_equal(linear_range_values_count(&r[2]), 7U); in ZTEST()
53 zassert_equal(linear_range_values_count(&r[3]), 2U); in ZTEST()
55 zassert_equal(linear_range_group_values_count(r, r_cnt), 13U); in ZTEST()
60 zassert_equal(linear_range_get_max_value(&r[0]), -5); in ZTEST()
61 zassert_equal(linear_range_get_max_value(&r[1]), 1); in ZTEST()
62 zassert_equal(linear_range_get_max_value(&r[2]), 280); in ZTEST()
63 zassert_equal(linear_range_get_max_value(&r[3]), 400); in ZTEST()
71 ret = linear_range_get_value(&r[0], 0U, &val); in ZTEST()
73 zassert_equal(val, -10); in ZTEST()
75 ret = linear_range_get_value(&r[0], 1U, &val); in ZTEST()
77 zassert_equal(val, -5); in ZTEST()
79 ret = linear_range_get_value(&r[1], 2U, &val); in ZTEST()
83 ret = linear_range_get_value(&r[1], 3U, &val); in ZTEST()
87 ret = linear_range_get_value(&r[2], 4U, &val); in ZTEST()
91 ret = linear_range_get_value(&r[2], 5U, &val); in ZTEST()
95 ret = linear_range_get_value(&r[2], 6U, &val); in ZTEST()
99 ret = linear_range_get_value(&r[2], 7U, &val); in ZTEST()
103 ret = linear_range_get_value(&r[2], 8U, &val); in ZTEST()
107 ret = linear_range_get_value(&r[2], 9U, &val); in ZTEST()
111 ret = linear_range_get_value(&r[2], 10U, &val); in ZTEST()
115 ret = linear_range_get_value(&r[3], 11U, &val); in ZTEST()
119 ret = linear_range_get_value(&r[3], 12U, &val); in ZTEST()
123 ret = linear_range_get_value(&r[1], 13U, &val); in ZTEST()
124 zassert_equal(ret, -EINVAL); in ZTEST()
126 ret = linear_range_group_get_value(r, r_cnt, 0U, &val); in ZTEST()
128 zassert_equal(val, -10); in ZTEST()
130 ret = linear_range_group_get_value(r, r_cnt, 1U, &val); in ZTEST()
132 zassert_equal(val, -5); in ZTEST()
134 ret = linear_range_group_get_value(r, r_cnt, 2U, &val); in ZTEST()
138 ret = linear_range_group_get_value(r, r_cnt, 3U, &val); in ZTEST()
142 ret = linear_range_group_get_value(r, r_cnt, 4U, &val); in ZTEST()
146 ret = linear_range_group_get_value(r, r_cnt, 5U, &val); in ZTEST()
150 ret = linear_range_group_get_value(r, r_cnt, 6U, &val); in ZTEST()
154 ret = linear_range_group_get_value(r, r_cnt, 7U, &val); in ZTEST()
158 ret = linear_range_group_get_value(r, r_cnt, 8U, &val); in ZTEST()
162 ret = linear_range_group_get_value(r, r_cnt, 9U, &val); in ZTEST()
166 ret = linear_range_group_get_value(r, r_cnt, 10U, &val); in ZTEST()
170 ret = linear_range_group_get_value(r, r_cnt, 11U, &val); in ZTEST()
174 ret = linear_range_group_get_value(r, r_cnt, 12U, &val); in ZTEST()
185 ret = linear_range_get_index(&r[0], -10, &idx); in ZTEST()
189 ret = linear_range_get_index(&r[0], -7, &idx); in ZTEST()
194 ret = linear_range_get_index(&r[1], -1, &idx); in ZTEST()
195 zassert_equal(ret, -ERANGE); in ZTEST()
198 ret = linear_range_get_index(&r[1], 2, &idx); in ZTEST()
199 zassert_equal(ret, -ERANGE); in ZTEST()
203 ret = linear_range_get_index(&r[2], 100, &idx); in ZTEST()
207 ret = linear_range_get_index(&r[2], 280, &idx); in ZTEST()
211 /* rounding: 120->130 (5) */ in ZTEST()
212 ret = linear_range_get_index(&r[2], 120, &idx); in ZTEST()
217 ret = linear_range_get_index(&r[3], 400, &idx); in ZTEST()
222 ret = linear_range_group_get_index(r, r_cnt, -20, &idx); in ZTEST()
223 zassert_equal(ret, -ERANGE); in ZTEST()
226 ret = linear_range_group_get_index(r, r_cnt, -6, &idx); in ZTEST()
230 ret = linear_range_group_get_index(r, r_cnt, 0, &idx); in ZTEST()
234 ret = linear_range_group_get_index(r, r_cnt, 50, &idx); in ZTEST()
235 zassert_equal(ret, -ERANGE); in ZTEST()
238 ret = linear_range_group_get_index(r, r_cnt, 200, &idx); in ZTEST()
242 ret = linear_range_group_get_index(r, r_cnt, 400, &idx); in ZTEST()
253 ret = linear_range_get_win_index(&r[0], -10, -6, &idx); in ZTEST()
257 ret = linear_range_get_win_index(&r[0], -7, -5, &idx); in ZTEST()
262 ret = linear_range_get_win_index(&r[0], -20, -15, &idx); in ZTEST()
263 zassert_equal(ret, -EINVAL); in ZTEST()
265 ret = linear_range_get_win_index(&r[0], -4, -3, &idx); in ZTEST()
266 zassert_equal(ret, -EINVAL); in ZTEST()
269 ret = linear_range_get_win_index(&r[1], -1, 0, &idx); in ZTEST()
270 zassert_equal(ret, -ERANGE); in ZTEST()
273 ret = linear_range_get_win_index(&r[1], 1, 2, &idx); in ZTEST()
274 zassert_equal(ret, -ERANGE); in ZTEST()
278 ret = linear_range_get_win_index(&r[2], 100, 100, &idx); in ZTEST()
283 ret = linear_range_get_win_index(&r[2], 100, 180, &idx); in ZTEST()
287 /* rounding: 120->130, maximum < 130 */ in ZTEST()
288 ret = linear_range_get_win_index(&r[2], 120, 140, &idx); in ZTEST()
292 /* rounding: 120->130, maximum > 125 (range too narrow) */ in ZTEST()
293 ret = linear_range_get_win_index(&r[2], 120, 125, &idx); in ZTEST()
294 zassert_equal(ret, -EINVAL); in ZTEST()
296 ret = linear_range_group_get_win_index(r, r_cnt, 120, 125, &idx); in ZTEST()
297 zassert_equal(ret, -EINVAL); in ZTEST()
300 ret = linear_range_get_win_index(&r[3], 400, 400, &idx); in ZTEST()
305 ret = linear_range_group_get_win_index(r, r_cnt, -10, -8, &idx); in ZTEST()
309 ret = linear_range_group_get_win_index(r, r_cnt, 0, 1, &idx); in ZTEST()
313 ret = linear_range_group_get_win_index(r, r_cnt, 1, 120, &idx); in ZTEST()
314 zassert_equal(ret, -ERANGE); in ZTEST()
317 ret = linear_range_group_get_win_index(r, r_cnt, 120, 140, &idx); in ZTEST()
321 ret = linear_range_group_get_win_index(r, r_cnt, 140, 400, &idx); in ZTEST()
322 zassert_equal(ret, -ERANGE); in ZTEST()
325 ret = linear_range_group_get_win_index(r, r_cnt, 400, 400, &idx); in ZTEST()
329 ret = linear_range_group_get_win_index(r, r_cnt, 300, 310, &idx); in ZTEST()
330 zassert_equal(ret, -EINVAL); in ZTEST()