Lines Matching refs:err
57 int err, r, s; in test_int_ops() local
60 err = 0; in test_int_ops()
61 r = safe_add_int(a, b, &err); in test_int_ops()
62 if (!TEST_int_eq(err, test_ints[n].sum_err) in test_int_ops()
63 || (!err && !TEST_int_eq(r, a + b))) in test_int_ops()
64 goto err; in test_int_ops()
66 err = 0; in test_int_ops()
67 r = safe_sub_int(a, b, &err); in test_int_ops()
68 if (!TEST_int_eq(err, test_ints[n].sub_err) in test_int_ops()
69 || (!err && !TEST_int_eq(r, a - b))) in test_int_ops()
70 goto err; in test_int_ops()
72 err = 0; in test_int_ops()
73 r = safe_mul_int(a, b, &err); in test_int_ops()
74 if (!TEST_int_eq(err, test_ints[n].mul_err) in test_int_ops()
75 || (!err && !TEST_int_eq(r, a * b))) in test_int_ops()
76 goto err; in test_int_ops()
78 err = 0; in test_int_ops()
79 r = safe_div_int(a, b, &err); in test_int_ops()
80 if (!TEST_int_eq(err, test_ints[n].div_err) in test_int_ops()
81 || (!err && !TEST_int_eq(r, a / b))) in test_int_ops()
82 goto err; in test_int_ops()
84 err = 0; in test_int_ops()
85 r = safe_mod_int(a, b, &err); in test_int_ops()
86 if (!TEST_int_eq(err, test_ints[n].mod_err) in test_int_ops()
87 || (!err && !TEST_int_eq(r, a % b))) in test_int_ops()
88 goto err; in test_int_ops()
90 err = 0; in test_int_ops()
91 r = safe_div_round_up_int(a, b, &err); in test_int_ops()
92 if (!TEST_int_eq(err, test_ints[n].div_round_up_err)) in test_int_ops()
93 goto err; in test_int_ops()
94 s = safe_mod_int(a, b, &err); in test_int_ops()
95 s = safe_add_int(safe_div_int(a, b, &err), s != 0, &err); in test_int_ops()
96 if (!err && !TEST_int_eq(r, s)) in test_int_ops()
97 goto err; in test_int_ops()
99 err = 0; in test_int_ops()
100 r = safe_neg_int(a, &err); in test_int_ops()
101 if (!TEST_int_eq(err, test_ints[n].neg_a_err) in test_int_ops()
102 || (!err && !TEST_int_eq(r, -a))) in test_int_ops()
103 goto err; in test_int_ops()
105 err = 0; in test_int_ops()
106 r = safe_neg_int(b, &err); in test_int_ops()
107 if (!TEST_int_eq(err, test_ints[n].neg_b_err) in test_int_ops()
108 || (!err && !TEST_int_eq(r, -b))) in test_int_ops()
109 goto err; in test_int_ops()
111 err = 0; in test_int_ops()
112 r = safe_abs_int(a, &err); in test_int_ops()
113 if (!TEST_int_eq(err, test_ints[n].abs_a_err) in test_int_ops()
114 || (!err && !TEST_int_eq(r, a < 0 ? -a : a))) in test_int_ops()
115 goto err; in test_int_ops()
117 err = 0; in test_int_ops()
118 r = safe_abs_int(b, &err); in test_int_ops()
119 if (!TEST_int_eq(err, test_ints[n].abs_b_err) in test_int_ops()
120 || (!err && !TEST_int_eq(r, b < 0 ? -b : b))) in test_int_ops()
121 goto err; in test_int_ops()
123 err: in test_int_ops()
124 TEST_info("a = %d b = %d r = %d err = %d", a, b, r, err); in test_int_ops()
145 int err; in test_uint_ops() local
149 err = 0; in test_uint_ops()
150 r = safe_add_uint(a, b, &err); in test_uint_ops()
151 if (!TEST_int_eq(err, test_uints[n].sum_err) in test_uint_ops()
152 || (!err && !TEST_uint_eq(r, a + b))) in test_uint_ops()
153 goto err; in test_uint_ops()
155 err = 0; in test_uint_ops()
156 r = safe_sub_uint(a, b, &err); in test_uint_ops()
157 if (!TEST_int_eq(err, test_uints[n].sub_err) in test_uint_ops()
158 || (!err && !TEST_uint_eq(r, a - b))) in test_uint_ops()
159 goto err; in test_uint_ops()
161 err = 0; in test_uint_ops()
162 r = safe_mul_uint(a, b, &err); in test_uint_ops()
163 if (!TEST_int_eq(err, test_uints[n].mul_err) in test_uint_ops()
164 || (!err && !TEST_uint_eq(r, a * b))) in test_uint_ops()
165 goto err; in test_uint_ops()
167 err = 0; in test_uint_ops()
168 r = safe_div_uint(a, b, &err); in test_uint_ops()
169 if (!TEST_int_eq(err, test_uints[n].div_err) in test_uint_ops()
170 || (!err && !TEST_uint_eq(r, a / b))) in test_uint_ops()
171 goto err; in test_uint_ops()
173 err = 0; in test_uint_ops()
174 r = safe_mod_uint(a, b, &err); in test_uint_ops()
175 if (!TEST_int_eq(err, test_uints[n].mod_err) in test_uint_ops()
176 || (!err && !TEST_uint_eq(r, a % b))) in test_uint_ops()
177 goto err; in test_uint_ops()
179 err = 0; in test_uint_ops()
180 r = safe_div_round_up_uint(a, b, &err); in test_uint_ops()
181 if (!TEST_int_eq(err, test_uints[n].div_round_up_err) in test_uint_ops()
182 || (!err && !TEST_uint_eq(r, a / b + (a % b != 0)))) in test_uint_ops()
183 goto err; in test_uint_ops()
185 err = 0; in test_uint_ops()
186 r = safe_neg_uint(a, &err); in test_uint_ops()
187 if (!TEST_int_eq(err, a != 0) || (!err && !TEST_uint_eq(r, 0))) in test_uint_ops()
188 goto err; in test_uint_ops()
190 err = 0; in test_uint_ops()
191 r = safe_neg_uint(b, &err); in test_uint_ops()
192 if (!TEST_int_eq(err, b != 0) || (!err && !TEST_uint_eq(r, 0))) in test_uint_ops()
193 goto err; in test_uint_ops()
195 err = 0; in test_uint_ops()
196 r = safe_abs_uint(a, &err); in test_uint_ops()
197 if (!TEST_int_eq(err, 0) || !TEST_uint_eq(r, a)) in test_uint_ops()
198 goto err; in test_uint_ops()
200 err = 0; in test_uint_ops()
201 r = safe_abs_uint(b, &err); in test_uint_ops()
202 if (!TEST_int_eq(err, 0) || !TEST_uint_eq(r, b)) in test_uint_ops()
203 goto err; in test_uint_ops()
205 err: in test_uint_ops()
206 TEST_info("a = %u b = %u r = %u err = %d", a, b, r, err); in test_uint_ops()
228 int err; in test_size_t_ops() local
232 err = 0; in test_size_t_ops()
233 r = safe_add_size_t(a, b, &err); in test_size_t_ops()
234 if (!TEST_int_eq(err, test_size_ts[n].sum_err) in test_size_t_ops()
235 || (!err && !TEST_size_t_eq(r, a + b))) in test_size_t_ops()
236 goto err; in test_size_t_ops()
238 err = 0; in test_size_t_ops()
239 r = safe_sub_size_t(a, b, &err); in test_size_t_ops()
240 if (!TEST_int_eq(err, test_size_ts[n].sub_err) in test_size_t_ops()
241 || (!err && !TEST_size_t_eq(r, a - b))) in test_size_t_ops()
242 goto err; in test_size_t_ops()
244 err = 0; in test_size_t_ops()
245 r = safe_mul_size_t(a, b, &err); in test_size_t_ops()
246 if (!TEST_int_eq(err, test_size_ts[n].mul_err) in test_size_t_ops()
247 || (!err && !TEST_size_t_eq(r, a * b))) in test_size_t_ops()
248 goto err; in test_size_t_ops()
250 err = 0; in test_size_t_ops()
251 r = safe_div_size_t(a, b, &err); in test_size_t_ops()
252 if (!TEST_int_eq(err, test_size_ts[n].div_err) in test_size_t_ops()
253 || (!err && !TEST_size_t_eq(r, a / b))) in test_size_t_ops()
254 goto err; in test_size_t_ops()
256 err = 0; in test_size_t_ops()
257 r = safe_mod_size_t(a, b, &err); in test_size_t_ops()
258 if (!TEST_int_eq(err, test_size_ts[n].mod_err) in test_size_t_ops()
259 || (!err && !TEST_size_t_eq(r, a % b))) in test_size_t_ops()
260 goto err; in test_size_t_ops()
262 err = 0; in test_size_t_ops()
263 r = safe_div_round_up_size_t(a, b, &err); in test_size_t_ops()
264 if (!TEST_int_eq(err, test_size_ts[n].div_round_up_err) in test_size_t_ops()
265 || (!err && !TEST_size_t_eq(r, a / b + (a % b != 0)))) in test_size_t_ops()
266 goto err; in test_size_t_ops()
268 err = 0; in test_size_t_ops()
269 r = safe_neg_size_t(a, &err); in test_size_t_ops()
270 if (!TEST_int_eq(err, a != 0) || (!err && !TEST_size_t_eq(r, 0))) in test_size_t_ops()
271 goto err; in test_size_t_ops()
273 err = 0; in test_size_t_ops()
274 r = safe_neg_size_t(b, &err); in test_size_t_ops()
275 if (!TEST_int_eq(err, b != 0) || (!err && !TEST_size_t_eq(r, 0))) in test_size_t_ops()
276 goto err; in test_size_t_ops()
278 err = 0; in test_size_t_ops()
279 r = safe_abs_size_t(a, &err); in test_size_t_ops()
280 if (!TEST_int_eq(err, 0) || !TEST_size_t_eq(r, a)) in test_size_t_ops()
281 goto err; in test_size_t_ops()
283 err = 0; in test_size_t_ops()
284 r = safe_abs_size_t(b, &err); in test_size_t_ops()
285 if (!TEST_int_eq(err, 0) || !TEST_size_t_eq(r, b)) in test_size_t_ops()
286 goto err; in test_size_t_ops()
288 err: in test_size_t_ops()
289 TEST_info("a = %zu b = %zu r = %zu err = %d", a, b, r, err); in test_size_t_ops()
295 int err; member
315 int err = 0; in test_int_muldiv() local
321 r = safe_muldiv_int(a, b, c, &err); in test_int_muldiv()
324 if (!TEST_int_eq(err, test_muldiv_ints[n].err) in test_int_muldiv()
325 || (!err && !TEST_int_eq(r, real))) { in test_int_muldiv()
326 TEST_info("%d * %d / %d r = %d err = %d", a, b, c, r, err); in test_int_muldiv()
334 int err; member
347 int err = 0; in test_uint_muldiv() local
353 r = safe_muldiv_uint(a, b, c, &err); in test_uint_muldiv()
356 if (!TEST_int_eq(err, test_muldiv_uints[n].err) in test_uint_muldiv()
357 || (!err && !TEST_uint_eq(r, real))) { in test_uint_muldiv()
358 TEST_info("%u * %u / %u r = %u err = %d", a, b, c, r, err); in test_uint_muldiv()