Skip to content

Commit fb0d20a

Browse files
author
Jake Moss
committed
Convert other tests to use TEST_FUNCTION_FAIL
1 parent 27c25e9 commit fb0d20a

File tree

3 files changed

+40
-204
lines changed

3 files changed

+40
-204
lines changed

src/fmpq_mpoly/test/t-compose_fmpq_mpoly.c

Lines changed: 14 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -44,34 +44,20 @@ TEST_FUNCTION_START(fmpq_mpoly_compose_fmpq_mpoly, state)
4444
fmpq_mpoly_set_str_pretty(C + 1, "x1 - x2", NULL, ctxAC);
4545
fmpq_mpoly_set_str_pretty(C + 2, "1", NULL, ctxAC);
4646
if (fmpq_mpoly_compose_fmpq_mpoly(A, B, Cp, ctxB, ctxAC))
47-
{
48-
printf("FAIL\n");
49-
flint_printf("Check non-example 1\n", i);
50-
fflush(stdout);
51-
flint_abort();
52-
}
47+
TEST_FUNCTION_FAIL("Check non-example 1\n", i);
5348

5449
fmpq_mpoly_set_str_pretty(C + 0, "x1", NULL, ctxAC);
5550
fmpq_mpoly_set_str_pretty(C + 1, "2*x2", NULL, ctxAC);
5651
fmpq_mpoly_set_str_pretty(C + 2, "1", NULL, ctxAC);
5752
if (fmpq_mpoly_compose_fmpq_mpoly(A, B, Cp, ctxB, ctxAC))
58-
{
59-
printf("FAIL\n");
60-
flint_printf("Check non-example 2\n", i);
61-
fflush(stdout);
62-
flint_abort();
63-
}
53+
TEST_FUNCTION_FAIL("Check non-example 2\n", i);
6454

6555
fmpq_mpoly_set_str_pretty(C + 0, "2*x1", NULL, ctxAC);
6656
fmpq_mpoly_set_str_pretty(C + 1, "x2", NULL, ctxAC);
6757
fmpq_mpoly_set_str_pretty(C + 2, "1", NULL, ctxAC);
6858
if (!fmpq_mpoly_compose_fmpq_mpoly(A, B, Cp, ctxB, ctxAC))
69-
{
70-
printf("FAIL\n");
71-
flint_printf("Check example 3\n", i);
72-
fflush(stdout);
73-
flint_abort();
74-
}
59+
TEST_FUNCTION_FAIL("Check example 3\n", i);
60+
7561
/* Aliased generator composition */
7662
c = (slong *) flint_malloc(nvarsB*sizeof(slong));
7763
fmpq_mpoly_init(B1, ctxB);
@@ -169,22 +155,12 @@ TEST_FUNCTION_START(fmpq_mpoly_compose_fmpq_mpoly, state)
169155
fmpq_mpoly_compose_fmpq_mpoly_gen(A, B, c, ctxB, ctxAC);
170156

171157
if (!fmpq_mpoly_compose_fmpq_mpoly(A1, B, C, ctxB, ctxAC))
172-
{
173-
printf("FAIL\n");
174-
flint_printf("Check composition success with generators\n"
175-
"i: %wd, j: %wd\n", i, j);
176-
fflush(stdout);
177-
flint_abort();
178-
}
158+
TEST_FUNCTION_FAIL("Check composition success with generators\n"
159+
"i: %wd, j: %wd\n", i, j);
179160

180161
if (!fmpq_mpoly_equal(A, A1, ctxAC))
181-
{
182-
printf("FAIL\n");
183-
flint_printf("Check composition with generators\n"
184-
"i: %wd, j: %wd\n", i, j);
185-
fflush(stdout);
186-
flint_abort();
187-
}
162+
TEST_FUNCTION_FAIL("Check composition with generators\n"
163+
"i: %wd, j: %wd\n", i, j);
188164

189165
fmpq_mpoly_assert_canonical(A, ctxAC);
190166
fmpq_mpoly_assert_canonical(A1, ctxAC);
@@ -234,20 +210,10 @@ TEST_FUNCTION_START(fmpq_mpoly_compose_fmpq_mpoly, state)
234210
coeff_bits = n_randint(state, 100) + 1;
235211
fmpq_mpoly_randtest_bits(f, state, len1, coeff_bits, exp_bits, ctx);
236212
if (!fmpq_mpoly_compose_fmpq_mpoly(g, f, vals1, ctx, ctx))
237-
{
238-
printf("FAIL\n");
239-
flint_printf("Check composition success\ni: %wd\n", i);
240-
fflush(stdout);
241-
flint_abort();
242-
}
213+
TEST_FUNCTION_FAIL("Check composition success\ni: %wd\n", i);
243214

244215
if (!fmpq_mpoly_equal(f, g, ctx))
245-
{
246-
printf("FAIL\n");
247-
flint_printf("Check composition with identity\ni: %wd\n", i);
248-
fflush(stdout);
249-
flint_abort();
250-
}
216+
TEST_FUNCTION_FAIL("Check composition with identity\ni: %wd\n", i);
251217

252218
fmpq_mpoly_clear(g, ctx);
253219
fmpq_mpoly_clear(f, ctx);
@@ -314,41 +280,21 @@ TEST_FUNCTION_START(fmpq_mpoly_compose_fmpq_mpoly, state)
314280
vals3[v] = (fmpq *) flint_malloc(sizeof(fmpq));
315281
fmpq_init(vals3[v]);
316282
if (!fmpq_mpoly_evaluate_all_fmpq(vals3[v], vals1[v], vals2, ctx2))
317-
{
318-
printf("FAIL\n");
319-
flint_printf("Check evaluation success\ni: %wd\n", i);
320-
fflush(stdout);
321-
flint_abort();
322-
}
283+
TEST_FUNCTION_FAIL("Check evaluation success\ni: %wd\n", i);
323284
}
324285

325286
fmpq_mpoly_randtest_bound(f, state, len1, coeff_bits, exp_bound1, ctx1);
326287

327288
if (!fmpq_mpoly_compose_fmpq_mpoly(g, f, vals1, ctx1, ctx2))
328-
{
329-
printf("FAIL\n");
330-
flint_printf("Check composition success\ni: %wd\n", i);
331-
fflush(stdout);
332-
flint_abort();
333-
}
289+
TEST_FUNCTION_FAIL("Check composition success\ni: %wd\n", i);
334290
fmpq_mpoly_assert_canonical(g, ctx2);
335291

336292
if (!fmpq_mpoly_evaluate_all_fmpq(fe, f, vals3, ctx1) ||
337293
!fmpq_mpoly_evaluate_all_fmpq(ge, g, vals2, ctx2))
338-
{
339-
printf("FAIL\n");
340-
flint_printf("Check evaluation success\ni: %wd\n", i);
341-
fflush(stdout);
342-
flint_abort();
343-
}
294+
TEST_FUNCTION_FAIL("Check evaluation success\ni: %wd\n", i);
344295

345296
if (!fmpq_equal(fe, ge))
346-
{
347-
printf("FAIL\n");
348-
flint_printf("Check composition and evalall commute\ni: %wd\n", i);
349-
fflush(stdout);
350-
flint_abort();
351-
}
297+
TEST_FUNCTION_FAIL("Check composition and evalall commute\ni: %wd\n", i);
352298

353299
for (v = 0; v < nvars1; v++)
354300
{

src/fmpz_mpoly/test/t-compose_fmpz_mpoly.c

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,23 @@ TEST_FUNCTION_START(fmpz_mpoly_compose_fmpz_mpoly, state)
4646
if (fmpz_mpoly_compose_fmpz_mpoly(A, B, Cp, ctxB, ctxAC) ||
4747
fmpz_mpoly_compose_fmpz_mpoly_horner(A1, B, Cp, ctxB, ctxAC) ||
4848
fmpz_mpoly_compose_fmpz_mpoly_geobucket(A2, B, Cp, ctxB, ctxAC))
49-
{
50-
printf("FAIL\n");
51-
flint_printf("Check non-example 1\n", i);
52-
fflush(stdout);
53-
flint_abort();
54-
}
49+
TEST_FUNCTION_FAIL("Check non-example 1\n", i);
5550

5651
fmpz_mpoly_set_str_pretty(C + 0, "x1", NULL, ctxAC);
5752
fmpz_mpoly_set_str_pretty(C + 1, "2*x2", NULL, ctxAC);
5853
fmpz_mpoly_set_str_pretty(C + 2, "1", NULL, ctxAC);
5954
if (fmpz_mpoly_compose_fmpz_mpoly(A, B, Cp, ctxB, ctxAC) ||
6055
fmpz_mpoly_compose_fmpz_mpoly_horner(A1, B, Cp, ctxB, ctxAC) ||
6156
fmpz_mpoly_compose_fmpz_mpoly_geobucket(A2, B, Cp, ctxB, ctxAC))
62-
{
63-
printf("FAIL\n");
64-
flint_printf("Check non-example 2\n", i);
65-
fflush(stdout);
66-
flint_abort();
67-
}
57+
TEST_FUNCTION_FAIL("Check non-example 2\n", i);
6858

6959
fmpz_mpoly_set_str_pretty(C + 0, "2*x1", NULL, ctxAC);
7060
fmpz_mpoly_set_str_pretty(C + 1, "x2", NULL, ctxAC);
7161
fmpz_mpoly_set_str_pretty(C + 2, "1", NULL, ctxAC);
7262
if (!fmpz_mpoly_compose_fmpz_mpoly(A, B, Cp, ctxB, ctxAC) ||
7363
!fmpz_mpoly_compose_fmpz_mpoly_horner(A1, B, Cp, ctxB, ctxAC) ||
7464
!fmpz_mpoly_compose_fmpz_mpoly_geobucket(A2, B, Cp, ctxB, ctxAC))
75-
{
76-
printf("FAIL\n");
77-
flint_printf("Check example 3\n", i);
78-
fflush(stdout);
79-
flint_abort();
80-
}
65+
TEST_FUNCTION_FAIL("Check example 3\n", i);
8166

8267
/* Aliased generator composition */
8368
c = (slong *) flint_malloc(nvarsB*sizeof(slong));
@@ -186,24 +171,14 @@ TEST_FUNCTION_START(fmpz_mpoly_compose_fmpz_mpoly, state)
186171
if (!fmpz_mpoly_compose_fmpz_mpoly(A1, B, C, ctxB, ctxAC) ||
187172
!fmpz_mpoly_compose_fmpz_mpoly_horner(A2, B, C, ctxB, ctxAC) ||
188173
!fmpz_mpoly_compose_fmpz_mpoly_geobucket(A3, B, C, ctxB, ctxAC))
189-
{
190-
printf("FAIL\n");
191-
flint_printf("Check composition success with generators\n"
192-
"i: %wd, j: %wd\n", i, j);
193-
fflush(stdout);
194-
flint_abort();
195-
}
174+
TEST_FUNCTION_FAIL("Check composition success with generators\n"
175+
"i: %wd, j: %wd\n", i, j);
196176

197177
if (!fmpz_mpoly_equal(A, A1, ctxAC) ||
198178
!fmpz_mpoly_equal(A, A2, ctxAC) ||
199179
!fmpz_mpoly_equal(A, A3, ctxAC))
200-
{
201-
printf("FAIL\n");
202-
flint_printf("Check composition with generators\n"
203-
"i: %wd, j: %wd\n", i, j);
204-
fflush(stdout);
205-
flint_abort();
206-
}
180+
TEST_FUNCTION_FAIL("Check composition with generators\n"
181+
"i: %wd, j: %wd\n", i, j);
207182

208183
fmpz_mpoly_assert_canonical(A, ctxAC);
209184
fmpz_mpoly_assert_canonical(A1, ctxAC);
@@ -264,24 +239,14 @@ TEST_FUNCTION_START(fmpz_mpoly_compose_fmpz_mpoly, state)
264239
!fmpz_mpoly_compose_fmpz_mpoly_geobucket(g2, f, vals1, ctx, ctx) ||
265240
!fmpz_mpoly_equal(g, g1, ctx) ||
266241
!fmpz_mpoly_equal(g, g2, ctx))
267-
{
268-
printf("FAIL\n");
269-
flint_printf("Check composition success\ni: %wd\n", i);
270-
fflush(stdout);
271-
flint_abort();
272-
}
242+
TEST_FUNCTION_FAIL("Check composition success\ni: %wd\n", i);
273243

274244
fmpz_mpoly_assert_canonical(g, ctx);
275245
fmpz_mpoly_assert_canonical(g1, ctx);
276246
fmpz_mpoly_assert_canonical(g2, ctx);
277247

278248
if (!fmpz_mpoly_equal(f, g, ctx))
279-
{
280-
printf("FAIL\n");
281-
flint_printf("Check composition with identity\ni: %wd\n", i);
282-
fflush(stdout);
283-
flint_abort();
284-
}
249+
TEST_FUNCTION_FAIL("Check composition with identity\ni: %wd\n", i);
285250

286251
fmpz_mpoly_clear(f, ctx);
287252
fmpz_mpoly_clear(g, ctx);
@@ -356,12 +321,7 @@ TEST_FUNCTION_START(fmpz_mpoly_compose_fmpz_mpoly, state)
356321
vals3[v] = (fmpz *) flint_malloc(sizeof(fmpz));
357322
fmpz_init(vals3[v]);
358323
if (!fmpz_mpoly_evaluate_all_fmpz(vals3[v], vals1[v], vals2, ctx2))
359-
{
360-
printf("FAIL\n");
361-
flint_printf("Check evaluation success\ni: %wd\n", i);
362-
fflush(stdout);
363-
flint_abort();
364-
}
324+
TEST_FUNCTION_FAIL("Check evaluation success\ni: %wd\n", i);
365325
}
366326

367327
fmpz_mpoly_randtest_bound(f, state, len1, coeff_bits1, exp_bound1, ctx1);
@@ -371,33 +331,18 @@ TEST_FUNCTION_START(fmpz_mpoly_compose_fmpz_mpoly, state)
371331
!fmpz_mpoly_compose_fmpz_mpoly_geobucket(g2, f, vals1, ctx1, ctx2) ||
372332
!fmpz_mpoly_equal(g, g1, ctx2) ||
373333
!fmpz_mpoly_equal(g, g2, ctx2))
374-
{
375-
printf("FAIL\n");
376-
flint_printf("Check composition success\ni: %wd\n", i);
377-
fflush(stdout);
378-
flint_abort();
379-
}
334+
TEST_FUNCTION_FAIL("Check composition success\ni: %wd\n", i);
380335

381336
fmpz_mpoly_assert_canonical(g, ctx2);
382337
fmpz_mpoly_assert_canonical(g1, ctx2);
383338
fmpz_mpoly_assert_canonical(g2, ctx2);
384339

385340
if (!fmpz_mpoly_evaluate_all_fmpz(fe, f, vals3, ctx1) ||
386341
!fmpz_mpoly_evaluate_all_fmpz(ge, g, vals2, ctx2))
387-
{
388-
printf("FAIL\n");
389-
flint_printf("Check evaluation success\ni: %wd\n", i);
390-
fflush(stdout);
391-
flint_abort();
392-
}
342+
TEST_FUNCTION_FAIL("Check evaluation success\ni: %wd\n", i);
393343

394344
if (!fmpz_equal(fe, ge))
395-
{
396-
printf("FAIL\n");
397-
flint_printf("Check composition and evalall commute\ni: %wd\n", i);
398-
fflush(stdout);
399-
flint_abort();
400-
}
345+
TEST_FUNCTION_FAIL("Check composition and evalall commute\ni: %wd\n", i);
401346

402347
for (v = 0; v < nvars1; v++)
403348
{

0 commit comments

Comments
 (0)