diff --git a/src/calculator.py b/src/calculator.py index 1292e98..db09d50 100644 --- a/src/calculator.py +++ b/src/calculator.py @@ -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 diff --git a/tests/test_calculator.py b/tests/test_calculator.py index 4365313..4e0aed2 100644 --- a/tests/test_calculator.py +++ b/tests/test_calculator.py @@ -1,6 +1,6 @@ import pytest -from src.calculator import add, divide +from src.calculator import add, divide, multiply def test_add(): @@ -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