Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ def divide(a: int, b: int) -> float:
if b == 0:
raise ValueError("除數不能為 0")
return a / b


def multiply(a: int, b: int) -> int:
"""兩數相乘"""
return a * b
6 changes: 5 additions & 1 deletion tests/test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from src.calculator import add, divide
from src.calculator import add, divide, multiply


def test_add():
Expand All @@ -14,3 +14,7 @@ def test_divide():
def test_divide_by_zero():
with pytest.raises(ValueError):
divide(1, 0)


def test_multiply():
assert multiply(2, 3) == 6
Loading