|
|
|
@ -85,16 +85,15 @@ CYBOZU_TEST_AUTO(setStr) |
|
|
|
|
{ "0b100", 4, 2 }, |
|
|
|
|
{ "0x100", 256, 0 }, |
|
|
|
|
{ "0x100", 256, 16 }, |
|
|
|
|
// use prefix if base conflicts with prefix
|
|
|
|
|
{ "0b100", 4, 16 }, |
|
|
|
|
{ "0x100", 256, 2 }, |
|
|
|
|
}; |
|
|
|
|
for (size_t i = 0; i < CYBOZU_NUM_OF_ARRAY(tbl); i++) { |
|
|
|
|
Fp x; |
|
|
|
|
x.setStr(tbl[i].in, tbl[i].base); |
|
|
|
|
CYBOZU_TEST_EQUAL(x, tbl[i].out); |
|
|
|
|
} |
|
|
|
|
// conflict prefix with base
|
|
|
|
|
Fp x; |
|
|
|
|
CYBOZU_TEST_EXCEPTION(x.setStr("0b100", 16), cybozu::Exception); |
|
|
|
|
CYBOZU_TEST_EXCEPTION(x.setStr("0x100", 2), cybozu::Exception); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CYBOZU_TEST_AUTO(stream) |
|
|
|
@ -121,9 +120,11 @@ CYBOZU_TEST_AUTO(stream) |
|
|
|
|
CYBOZU_TEST_EQUAL(x, tbl[i].out16); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// use prefix if base conflicts with prefix
|
|
|
|
|
std::istringstream is("0b100"); |
|
|
|
|
Fp x; |
|
|
|
|
CYBOZU_TEST_EXCEPTION(is >> std::hex >> x, cybozu::Exception); |
|
|
|
|
is >> std::hex >> x; |
|
|
|
|
CYBOZU_TEST_EQUAL(x, 4); |
|
|
|
|
{ |
|
|
|
|
std::ostringstream os; |
|
|
|
|
os << Fp(123); |
|
|
|
|