Add test for Carmichael pseudo-primes
parent
ba8882db39
commit
ffa92b09e6
26
validat0.cpp
26
validat0.cpp
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include "secblock.h"
|
#include "secblock.h"
|
||||||
#include "integer.h"
|
#include "integer.h"
|
||||||
|
#include "nbtheory.h"
|
||||||
#include "zdeflate.h"
|
#include "zdeflate.h"
|
||||||
#include "filters.h"
|
#include "filters.h"
|
||||||
#include "stdcpp.h"
|
#include "stdcpp.h"
|
||||||
|
|
@ -2151,13 +2152,12 @@ bool TestIntegerBitops()
|
||||||
std::cout << " Integer DivideByZero\n";
|
std::cout << " Integer DivideByZero\n";
|
||||||
|
|
||||||
// Integer is missing a couple of tests...
|
// Integer is missing a couple of tests...
|
||||||
|
pass=true;
|
||||||
try {
|
try {
|
||||||
// A run of 71 composites; see http://en.wikipedia.org/wiki/Prime_gap
|
// A run of 71 composites; see http://en.wikipedia.org/wiki/Prime_gap
|
||||||
Integer x = Integer(GlobalRNG(), 31398, 31468, Integer::PRIME);
|
Integer x = Integer(GlobalRNG(), 31398, 31468, Integer::PRIME);
|
||||||
pass=false;
|
pass=false;
|
||||||
} catch (const Exception&) {
|
} catch (const Exception&) { }
|
||||||
pass=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pass)
|
if (pass)
|
||||||
std::cout << "passed:";
|
std::cout << "passed:";
|
||||||
|
|
@ -2165,9 +2165,27 @@ bool TestIntegerBitops()
|
||||||
std::cout << "FAILED:";
|
std::cout << "FAILED:";
|
||||||
std::cout << " Integer RandomNumberNotFound\n";
|
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("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...
|
// Integer is missing a couple of tests...
|
||||||
try {
|
try {
|
||||||
// All in range [90, 96] are composite
|
|
||||||
Integer x = Integer::One().Doubled();
|
Integer x = Integer::One().Doubled();
|
||||||
pass=(x == Integer::Two());
|
pass=(x == Integer::Two());
|
||||||
} catch (const Exception&) {
|
} catch (const Exception&) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue