aboutsummaryrefslogtreecommitdiffstats
path: root/test/gmp_test.cpp
blob: 2d3e5632d9cd51f7d429a1e6b26c3cf159456acf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <mcl/gmp_util.hpp>
#include <vector>
#include <cybozu/test.hpp>

CYBOZU_TEST_AUTO(testBit)
{
    const size_t maxBit = 100;
    const size_t tbl[] = {
        3, 9, 5, 10, 50, maxBit
    };
    mpz_class a;
    std::vector<bool> b(maxBit + 1);
    for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
        a |= mpz_class(1) << tbl[i];
        b[tbl[i]] = 1;
    }
    for (size_t i = 0; i <= maxBit; i++) {
        bool c1 = mcl::gmp::testBit(a, i);
        bool c2 = b[i] != 0;
        CYBOZU_TEST_EQUAL(c1, c2);
    }
}