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

Function test

code/mathematics/tonelli_shanks.test.cpp:2–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "../code/mathematics/is_prime.cpp"
2void test() {
3 // Field testing: Project Euler 437
4 rep(it,0,10000) {
5 int n;
6 while (true) {
7 n = randint(2, 100000);
8 if (is_prime(n)) {
9 break;
10 }
11 }
12 int a;
13 while (true) {
14 a = randint(1,n-1);
15 if (leg(a, n) == 1) {
16 break;
17 }
18 }
19 ll res = tonelli_shanks(a, n);
20 assert_false(res == -1);
21 assert_equal<ll>(a, (res*res)%n);
22 }
23}
24// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 5

is_primeFunction · 0.85
legFunction · 0.85
tonelli_shanksFunction · 0.85
assert_falseFunction · 0.85
randintFunction · 0.70

Tested by

no test coverage detected