summaryrefslogtreecommitdiff
path: root/validat0.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-03-25 00:58:11 -0400
committerJeffrey Walton <noloader@gmail.com>2018-03-25 00:58:11 -0400
commiteb0d040786ffd41e517f51a6878e37b1de8ee334 (patch)
tree1fa27983cc2d3ddbad904fd0b4c83cfeb06f2b0e /validat0.cpp
parentff82b5a886d379899f8a4eb142c4fefb057e19c0 (diff)
downloadcryptopp-git-eb0d040786ffd41e517f51a6878e37b1de8ee334.tar.gz
Move some tests from TestIntegerBitops to TestIntegerOps (GH #602)
Diffstat (limited to 'validat0.cpp')
-rw-r--r--validat0.cpp125
1 files changed, 62 insertions, 63 deletions
diff --git a/validat0.cpp b/validat0.cpp
index 9ff983c3..d55f9ee4 100644
--- a/validat0.cpp
+++ b/validat0.cpp
@@ -2495,70 +2495,9 @@ bool TestHuffmanCodes()
#if defined(CRYPTOPP_EXTENDED_VALIDATION)
bool TestIntegerBitops()
{
- std::cout << "\nTesting Integer operations...\n\n";
+ std::cout << "\nTesting Integer bit operations...\n\n";
bool pass;
- // Integer is missing a couple of tests...
- try {
- Integer x = Integer::Two().Power2(128) / Integer::Zero();
- pass=false;
- } catch (const Exception&) {
- pass=true;
- }
-
- if (pass)
- std::cout << "passed:";
- else
- std::cout << "FAILED:";
- std::cout << " Integer DivideByZero\n";
-
- // Integer is missing a couple of tests...
- pass=true;
- try {
- // A run of 71 composites; see http://en.wikipedia.org/wiki/Prime_gap
- Integer x = Integer(GlobalRNG(), 31398, 31468, Integer::PRIME);
- pass=false;
- } catch (const Exception&) { }
-
- if (pass)
- std::cout << "passed:";
- else
- std::cout << "FAILED:";
- std::cout << " Integer RandomNumberNotFound\n";
-
- // Carmichael pseudo-primes
- pass=true;
- if (IsPrime(Integer("561")))
- pass = false;
- if (IsPrime(Integer("41041")))
- pass = false;
- if (IsPrime(Integer("321197185")))
- pass = false;
- if (IsPrime(Integer("5394826801")))
- pass = false;
- if (IsPrime(Integer("232250619601")))
- pass = false;
- if (IsPrime(Integer("974637772161")))
- pass = false;
-
- if (pass)
- std::cout << "passed:";
- else
- std::cout << "FAILED:";
- std::cout << " Carmichael pseudo-primes\n";
-
- // Integer is missing a couple of tests...
- try {
- Integer x = Integer::One().Doubled();
- pass=(x == Integer::Two());
- } catch (const Exception&) {
- pass=false;
- }
-
- if (!pass)
- std::cout << "FAILED: Integer Doubled\n";
-
- // Now onto the meat and potatoes...
struct Bitops_TestTuple
{
// m,n are operands; a,o,x are and,or,xor results
@@ -3199,6 +3138,66 @@ bool TestIntegerOps()
std::cout << "\nTesting Integer operations...\n\n";
bool pass=true, result;
+ // Integer is missing a couple of tests...
+ try {
+ Integer x = Integer::Two().Power2(128) / Integer::Zero();
+ pass=false;
+ } catch (const Exception&) {
+ pass=true;
+ }
+
+ if (pass)
+ std::cout << "passed:";
+ else
+ std::cout << "FAILED:";
+ std::cout << " Integer DivideByZero\n";
+
+ // Integer is missing a couple of tests...
+ pass=true;
+ try {
+ // A run of 71 composites; see http://en.wikipedia.org/wiki/Prime_gap
+ Integer x = Integer(GlobalRNG(), 31398, 31468, Integer::PRIME);
+ pass=false;
+ } catch (const Exception&) { }
+
+ if (pass)
+ std::cout << "passed:";
+ else
+ std::cout << "FAILED:";
+ std::cout << " Integer RandomNumberNotFound\n";
+
+ // Carmichael pseudo-primes
+ pass=true;
+ if (IsPrime(Integer("561")))
+ pass = false;
+ if (IsPrime(Integer("41041")))
+ pass = false;
+ if (IsPrime(Integer("321197185")))
+ pass = false;
+ if (IsPrime(Integer("5394826801")))
+ pass = false;
+ if (IsPrime(Integer("232250619601")))
+ pass = false;
+ if (IsPrime(Integer("974637772161")))
+ pass = false;
+
+ if (pass)
+ std::cout << "passed:";
+ else
+ std::cout << "FAILED:";
+ std::cout << " Carmichael pseudo-primes\n";
+
+ // Integer is missing a couple of tests...
+ try {
+ Integer x = Integer::One().Doubled();
+ pass=(x == Integer::Two());
+ } catch (const Exception&) {
+ pass=false;
+ }
+
+ if (!pass)
+ std::cout << "FAILED: Integer Doubled\n";
+
// http://github.com/weidai11/cryptopp/issues/602
Integer a("0x2F0500010000018000000000001C1C000000000000000A000B0000000000000000000000000000FDFFFFFF00000000");
Integer b("0x3D2F050001");
@@ -3311,7 +3310,7 @@ bool TestIntegerOps()
std::cout << "passed:";
else
std::cout << "FAILED:";
- std::cout << " Integer::InverseMod operations\n";
+ std::cout << " InverseMod operations\n";
return pass;
}