You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
475 B
24 lines
475 B
9 years ago
|
#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);
|
||
|
}
|
||
|
}
|
||
|
|