Skip to content

Commit

Permalink
added test to the problems
Browse files Browse the repository at this point in the history
  • Loading branch information
nasratmn committed Jan 12, 2025
1 parent c9577ab commit 389f8a7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions solutions/tests/test 5-calculate-the-factorial-of-a-number
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Testing the function
test_cases = [5, 0, 7, -1, 10] # Adding a negative number to check error handling

# Displaying the results
for num in test_cases:
try:
if num < 0:
raise ValueError(f"Factorial is not defined for negative numbers: {num}")
result = calculate_factorial(num)
print(f"Input: {num}, Output: {result}")
except ValueError as e:
print(e)

0 comments on commit 389f8a7

Please sign in to comment.