fabelous-math/tests/functions/test_simple_functions.py

62 lines
1.7 KiB
Python

import pytest
from fabelous_math import is_even, is_odd
def test_is_even():
# Test positive even numbers
assert is_even(0) == True
assert is_even(2) == True
assert is_even(4) == True
assert is_even(100) == True
# Test positive odd numbers
assert is_even(1) == False
assert is_even(3) == False
assert is_even(99) == False
# Test negative even numbers
assert is_even(-2) == True
assert is_even(-4) == True
assert is_even(-100) == True
# Test negative odd numbers
assert is_even(-1) == False
assert is_even(-3) == False
assert is_even(-99) == False
# Test large numbers
assert is_even(1000000) == True
assert is_even(-1000001) == False
def test_is_odd():
# Test positive odd numbers
assert is_odd(1) == True
assert is_odd(3) == True
assert is_odd(99) == True
# Test positive even numbers
assert is_odd(0) == False
assert is_odd(2) == False
assert is_odd(4) == False
assert is_odd(100) == False
# Test negative odd numbers
assert is_odd(-1) == True
assert is_odd(-3) == True
assert is_odd(-99) == True
# Test negative even numbers
assert is_odd(-2) == False
assert is_odd(-4) == False
assert is_odd(-100) == False
# Test large numbers
assert is_odd(1000001) == True
assert is_odd(-1000000) == False
def test_is_even_is_odd_complementary():
# Ensure is_even and is_odd are complementary for various numbers
test_numbers = [0, 1, -1, 2, -2, 99, -99, 1000000, -1000001]
for num in test_numbers:
assert is_even(num) != is_odd(num), \
f"Failed for number {num}: is_even and is_odd should be opposite"