summaryrefslogtreecommitdiff
path: root/tests/test-BigInt.cc
blob: 56f195b65ef43ced30e882f798b87f6366ec6397 (plain)
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
#include <Main.h>
#include <BigInt.h>

using namespace Balau;

void MainTask::Do() {
    Printer::log(M_STATUS, "Test::BigInt running.");

    {
        BigInt a, b;
        uint64_t t = 10000000000000000000;
        String s =  "10000000000000000000";
        a.set(t);
        b.set(s);
        TAssert(a == b);
        TAssert(a.toString() == s);
    }

    {
        BigInt a, b, m, r, c;

        // random values; c is computed by wolfram alpha.
        a.set("23475098273405987234905872394051923847902348567");
        b.set("3234057230495872034923458723049857203948572039485734598276345987");
        m.set("534287528093746598127364987236459872634587");

        c.set("211833264233843026809053124694679687014311");

        r = a.modpow(b, m);

        TAssert(r == c);
    }

    Printer::log(M_STATUS, "Test::BigInt passed.");
}