MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / test

Function test

code/mathematics/egcd.test.cpp:1–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1void test() {
2 ll x, y;
3
4 assert_equal(3LL * 5, egcd(2 * 3 * 5 * 5 * 11, 3 * 5 * 13, x, y));
5 assert_equal(-2LL, x);
6 assert_equal(17LL, y);
7
8 assert_equal(3LL * 5, egcd(2 * 3 * 5 * 5 * 11, 3 * 5 * 13 * 17, x, y));
9 assert_equal(-2LL, x);
10 assert_equal(1LL, y);
11
12 assert_equal(3LL * 5, egcd(2 * 3 * 5 * 11, 3 * 5 * 13 * 17, x, y));
13 assert_equal(-10LL, x);
14 assert_equal(1LL, y);
15
16 assert_equal(3LL * 5, egcd(3 * 5 * 11, 3 * 5 * 13 * 17, x, y));
17 assert_equal(-20LL, x);
18 assert_equal(1LL, y);
19
20 assert_equal(3LL * 5, egcd(3 * 5 * 11, 3 * 3 * 5 * 13 * 17, x, y));
21 assert_equal(-241LL, x);
22 assert_equal(4LL, y);
23
24 assert_equal(3LL * 3 * 5, egcd(3 * 3 * 5 * 11, 3 * 3 * 5 * 13 * 17, x, y));
25 assert_equal(-20LL, x);
26 assert_equal(1LL, y);
27
28 // assert_equal(3 * 3 * 5, egcd(-1 * 3 * 3 * 5 * 11, 3 * 3 * 5 * 13 * 17, x, y));
29 // assert_equal(20, x);
30 // assert_equal(1, y);
31
32 // assert_equal(3 * 3 * 5, egcd(3 * 3 * 5 * 11, -1 * 3 * 3 * 5 * 13 * 17, x, y));
33 // assert_equal(-20, x);
34 // assert_equal(-1, y);
35
36 // assert_equal(-1 * 3 * 3 * 5, egcd(-1 * 3 * 3 * 5 * 11, -1 * 3 * 3 * 5 * 13 * 17, x, y));
37 // assert_equal(20, x);
38 // assert_equal(-1, y);
39
40 assert_equal(1LL, egcd(3424, 23423, x, y));
41 assert_equal(1977LL, x);
42 assert_equal(-289LL, y);
43
44 for (ll a = 0; a < 20; a++)
45 for (ll b = 0; b < 20; b++) {
46 assert_equal(egcd(a, b, x, y), egcd(b, a, x, y));
47 assert_equal(egcd(a, b, x, y), a * x + b * y);
48 }
49
50 for (ll a = 0; a < 100; a++) {
51 assert_equal(a, egcd(a, a, x, y));
52 assert_equal(1LL, egcd(1, a, x, y));
53 assert_equal(1LL, egcd(a, 1, x, y));
54 }
55}
56// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 2

egcdFunction · 0.85
assert_equalFunction · 0.50

Tested by

no test coverage detected