from src import get_cache_size
from src.primesgen import Eratosthenes, IndexedEratosthenes

segment_size = get_cache_size()


def test_100_000(): assert_len_at(100_000)


def test_1_000_000(): assert_len_at(1_000_000)


def test_10_000_000(): assert_len_at(10_000_000)


def test_100_000_000(): assert_len_at(100_000_000)


def test_35_123_231(): assert_len_at(35_123_231)


def assert_len_at(max_val):
    c_primes = Eratosthenes().primes(max_val)
    c_len = len(c_primes)
    c_primes.clear()

    i_primes = IndexedEratosthenes().primes(max_val)
    i_len = len(i_primes)
    i_primes.clear()

    assert c_len == i_len, f'{max_val}, lengths differ ({c_len}, {i_len})'
