1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Copyright (C) 2011 Fredrik Johansson
Copyright (C) 2014 William Hart
This file is part of FLINT.
FLINT is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version. See <https://www.gnu.org/licenses/>.
*/
#include "test_helpers.h"
#include "long_extras.h"
#include "fmpq.h"
TEST_FUNCTION_START(fmpq_add_si, state)
{
int i, result;
for (i = 0; i < 10000 * flint_test_multiplier(); i++)
{
fmpq_t a;
slong b;
fmpq_t c, d, e, f;
int aliasing;
fmpq_init(a);
fmpq_init(c);
fmpq_init(d);
fmpq_init(e);
fmpq_init(f);
fmpq_randtest(a, state, 200);
b = z_randtest(state);
fmpq_set(d, a);
fmpq_set_si(e, b, 1);
aliasing = n_randint(state, 2);
if (aliasing == 0)
{
fmpq_add_si(c, a, b);
}
else
{
fmpq_set(c, a);
fmpq_add_si(c, c, b);
}
fmpq_add(f, d, e);
result = (fmpq_cmp(f, c) == 0) && fmpq_is_canonical(c);
if (!result)
{
flint_printf("FAIL:\n");
printf("c = "); fmpq_print(c);
printf(", d = "); fmpq_print(d);
printf(", e = "); fmpq_print(e);
printf(", f = "); fmpq_print(f); printf("\n");
fflush(stdout);
flint_abort();
}
fmpq_clear(a);
fmpq_clear(c);
fmpq_clear(d);
fmpq_clear(e);
fmpq_clear(f);
}
TEST_FUNCTION_END(state);
}