# Path: mom/_prime_sieve.py
# def make_prime_sieve(max_n):  # def _numpy_primesfrom2to(max_n):
# def make_prime_sieve(max_n):  # def _rwh_primes1(max_n):
# 
# Path: mom/math.py
# def gcd(num_a, num_b):
# def lcm(num_a, num_b):
# def inverse_mod(num_a, num_b):
# def exact_log2(number):
# def _pure_pow_mod(base, power, modulus):
# def _pure_is_prime(num, iterations=5, _sieve=prime_sieve.SIEVE):
# def generate_random_prime(bits):
# def generate_random_safe_prime(bits):


import unittest2
from mom import _prime_sieve
from mom import math




__author__ = "yesudeep@google.com (Yesudeep Mangalapilly)"


class Test__pure_is_prime(unittest2.TestCase):
  def test_pure_is_prime_for_sieves(self):
    for i in [10, 100, 1000, 10000]:
      sieve = _prime_sieve.make_prime_sieve(i)
      odds = []
      for x in sieve:
        if not math._pure_is_prime(x, _sieve=[2, 3]):
          odds.append(x)
      self.assertEqual(odds, [])

  def test_non_prime_by_sieve(self):
    self.assertFalse(math._pure_is_prime(100))


class Test_generate_random_prime(unittest2.TestCase):
  def test_generate_random_prime(self):
    for _ in range(100):
      self.assertTrue(math.is_prime(math.generate_random_prime(64)))


class Test_generate_random_safe_prime(unittest2.TestCase):
  def test_generate_random_safe_prime(self):
    for _ in range(20):

# Path: mom/_prime_sieve.py
# def make_prime_sieve(max_n):  # def _numpy_primesfrom2to(max_n):
# def make_prime_sieve(max_n):  # def _rwh_primes1(max_n):
# 
# Path: mom/math.py
# def gcd(num_a, num_b):
# def lcm(num_a, num_b):
# def inverse_mod(num_a, num_b):
# def exact_log2(number):
# def _pure_pow_mod(base, power, modulus):
# def _pure_is_prime(num, iterations=5, _sieve=prime_sieve.SIEVE):
# def generate_random_prime(bits):
# def generate_random_safe_prime(bits):


# Path: mom/tests/test_mom_math.py
import unittest2
from mom import _prime_sieve
from mom import math





__author__ = "yesudeep@google.com (Yesudeep Mangalapilly)"


class Test__pure_is_prime(unittest2.TestCase):
  def test_pure_is_prime_for_sieves(self):
    for i in [10, 100, 1000, 10000]:
      sieve = _prime_sieve.make_prime_sieve(i)
      odds = []
      for x in sieve:
        if not math._pure_is_prime(x, _sieve=[2, 3]):
          odds.append(x)
      self.assertEqual(odds, [])

  def test_non_prime_by_sieve(self):
    self.assertFalse(math._pure_is_prime(100))


class Test_generate_random_prime(unittest2.TestCase):
  def test_generate_random_prime(self):
    for _ in range(100):
      self.assertTrue(math.is_prime(math.generate_random_prime(64)))


class Test_generate_random_safe_prime(unittest2.TestCase):
  def test_generate_random_safe_prime(self):
    for _ in range(20):

      self.assertTrue(math.is_prime(math.generate_random_safe_prime(32)))