Exemplo n.º 1
0
int main() {

	auto t0 = std::chrono::high_resolution_clock::now();

	Primes pr;

	std::cout << "Testing function Primes::is_prime" << std::endl;
	print_pass_fail(test_is_prime(pr, 2, true));
	print_pass_fail(test_is_prime(pr, 1300979, true));
	print_pass_fail(test_is_prime(pr, 2453422, false));

	std::cout << "Testing function Primes::is_divisble_by" << std::endl;
	print_pass_fail(test_is_divisible_by(pr, 4, 2, true));
	print_pass_fail(test_is_divisible_by(pr, 5, 2, false));
	print_pass_fail(test_is_divisible_by(pr, 2453422, 2, true));

	std::cout << "Testing function Primes::get_smallest_prime_divisor" << std::endl;
	print_pass_fail(test_get_smallest_prime_divisor(pr, 2, 2));
	print_pass_fail(test_get_smallest_prime_divisor(pr, 49, 7));
	print_pass_fail(test_get_smallest_prime_divisor(pr, 1300979, 1300979));

	auto t1 = std::chrono::high_resolution_clock::now();
	std::cout << "Tests completed in " 
						<< std::chrono::duration_cast<std::chrono::milliseconds>(t1-t0).count() 
						<< " ms"
						<< std::endl;
}
Exemplo n.º 2
0
int main(void)
{
   rand_t state;
   randinit(state);
   
   test_addsub(state);
   test_muldiv(state);
   test_divdivrem(state);
   test_gcd(state);
   test_jacobi(state);
   test_fib(state);
   test_is_prime(state);

   return 0;
}