예제 #1
0
def test_compute_product_small_list_mpz(compute_product, n):

    random.seed(n)

    xs = [mpz(random.randint(-42, 42)) for i in range(n)]
    ys = copy.copy(xs)

    result = mpz(1)
    for y in ys:
        result *= y

    assert compute_product(xs) == result, "Simple none-zero product with mpz"
예제 #2
0
def test_compute_product_small_list(compute_product, n):

    random.seed(n)

    xs = [random.randint(-42, 42) for i in range(n)]
    ys = copy.copy(xs)

    result = 1
    for y in ys:
        result *= y

    assert compute_product(xs) == result, "Simple non-zero list product failed"
예제 #3
0
def test_compute_product_single(compute_product, n):

    assert compute_product([n]) == n, "Single element must be unchanged"
예제 #4
0
def test_compute_product_empty(compute_product):

    assert compute_product([]) == 0, "Empty list must have product 0"