|
|
@ -6,21 +6,24 @@ |
|
|
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(ArrayIterator) |
|
|
|
CYBOZU_TEST_AUTO(ArrayIterator) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint32_t in[2] = { 0x12345678, 0xabcdef89 }; |
|
|
|
const uint32_t in[] = { 0x12345678, 0xabcdef89, 0xaabbccdd }; |
|
|
|
const size_t bitSize = 64; |
|
|
|
for (size_t bitSize = 1; bitSize <= 64; bitSize++) { |
|
|
|
for (size_t w = 1; w <= 32; w++) { |
|
|
|
for (size_t w = 1; w <= 32; w++) { |
|
|
|
const uint32_t mask = uint32_t((uint64_t(1) << w) - 1); |
|
|
|
|
|
|
|
mpz_class x; |
|
|
|
const uint32_t mask = uint32_t((uint64_t(1) << w) - 1); |
|
|
|
mcl::gmp::setArray(x, in, 2); |
|
|
|
mpz_class x; |
|
|
|
mcl::fp::ArrayIterator<uint32_t> ai(in, bitSize, w); |
|
|
|
mcl::gmp::setArray(x, in, CYBOZU_NUM_OF_ARRAY(in)); |
|
|
|
size_t n = (bitSize + w - 1) / w; |
|
|
|
x &= (mpz_class(1) << bitSize) - 1; |
|
|
|
for (size_t j = 0; j < n; j++) { |
|
|
|
mcl::fp::ArrayIterator<uint32_t> ai(in, bitSize, w); |
|
|
|
CYBOZU_TEST_ASSERT(ai.hasNext()); |
|
|
|
size_t n = (bitSize + w - 1) / w; |
|
|
|
uint32_t v = ai.getNext(); |
|
|
|
for (size_t j = 0; j < n; j++) { |
|
|
|
CYBOZU_TEST_EQUAL(x & mask, v); |
|
|
|
CYBOZU_TEST_ASSERT(ai.hasNext()); |
|
|
|
x >>= w; |
|
|
|
uint32_t v = ai.getNext(); |
|
|
|
|
|
|
|
CYBOZU_TEST_EQUAL(x & mask, v); |
|
|
|
|
|
|
|
x >>= w; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CYBOZU_TEST_ASSERT(!ai.hasNext()); |
|
|
|
} |
|
|
|
} |
|
|
|
CYBOZU_TEST_ASSERT(!ai.hasNext()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|