aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2019-04-18 16:32:36 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2019-04-24 16:12:10 +0800
commit2b3835260a7a594214bec51fb46e105634145c31 (patch)
treeb174b27fd3bc8a5cdbbf557cca2f1c5bba721f0d
parent3adee27f18a8a8ff56d2f78edbdb1e1e8bcca4f4 (diff)
downloadtangerine-mcl-2b3835260a7a594214bec51fb46e105634145c31.tar.gz
tangerine-mcl-2b3835260a7a594214bec51fb46e105634145c31.tar.zst
tangerine-mcl-2b3835260a7a594214bec51fb46e105634145c31.zip
avoid overflow in test
-rw-r--r--test/fp_test.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/test/fp_test.cpp b/test/fp_test.cpp
index dc1b01e..d82c30f 100644
--- a/test/fp_test.cpp
+++ b/test/fp_test.cpp
@@ -567,7 +567,8 @@ void setArrayMaskTest2(mcl::fp::Mode mode)
void setArrayModTest()
{
const mpz_class& p = Fp::getOp().mp;
- const mpz_class tbl[] = {
+ mpz_class tbl[] = {
+ 0, // max
0,
1,
p - 1,
@@ -582,8 +583,9 @@ void setArrayModTest()
p * p - 1,
p * p,
p * p + 1,
- (mpz_class(1) << Fp::getOp().N * mcl::fp::UnitBitSize * 2) - 1,
};
+ std::string maxStr(mcl::gmp::getBitSize(p) * 2, '1');
+ mcl::gmp::setStr(tbl[0], maxStr, 2);
const size_t unitByteSize = sizeof(mcl::fp::Unit);
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {
const mpz_class& x = tbl[i];
@@ -816,7 +818,8 @@ void serializeTest()
void modpTest()
{
const mpz_class& p = Fp::getOp().mp;
- const mpz_class tbl[] = {
+ mpz_class tbl[] = {
+ 0, // max
0,
1,
p - 1,
@@ -831,8 +834,9 @@ void modpTest()
p * p - 1,
p * p,
p * p + 1,
- (mpz_class(1) << Fp::getOp().N * mcl::fp::UnitBitSize * 2) - 1,
};
+ std::string maxStr(mcl::gmp::getBitSize(p) * 2, '1');
+ mcl::gmp::setStr(tbl[0], maxStr, 2);
mcl::Modp modp;
modp.init(p);
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) {