fabelous-math/tests/functions/test_pi.py

25 lines
1.1 KiB
Python

import pytest
from fabelous_math import approximate_pi
def test_approximate_pi():
# Test with a known precision value
precision = 10000
pi_approx = approximate_pi(precision)
assert isinstance(pi_approx, float), "The result should be a float"
assert pi_approx > 3.14, "The approximation of Pi should be greater than 3.14"
assert pi_approx < 3.15, "The approximation of Pi should be less than 3.15"
def test_approximate_pi_with_low_precision():
# Test with a low precision value
precision = 100
pi_approx = approximate_pi(precision)
assert isinstance(pi_approx, float), "The result should be a float"
assert pi_approx > 3.0, "The approximation of Pi should be greater than 3.0"
assert pi_approx < 4.0, "The approximation of Pi should be less than 4.0"
def test_approximate_pi_with_high_precision():
# Test with a high precision value
precision = 10000000
pi_approx = approximate_pi(precision)
assert isinstance(pi_approx, float), "The result should be a float"
assert pi_approx > 3.1415926533, "The approximation of Pi should be greater than the known value of Pi"