Skip to content
Open
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
Binary file added __pycache__/calculator.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/test_calculator.cpython-39.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions calculator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

class Calculator:
def add(self, a, b):
return a + b
Expand Down
65 changes: 65 additions & 0 deletions clear
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
commit a78cb6ab1c920e585c15f0fbfb8a83e90c206b6b (HEAD, origin/master, origin/HEAD)
Author: alex2521-code <thanakrit.tae@mahidol.ac.th>
Date: Thu Nov 13 02:32:39 2025 +0000

Test commit 2

commit 970f08e6de52b87bb7b0f4d1511c4dd1d37a73f1
Author: alex2521-code <thanakrit.tae@mahidol.ac.th>
Date: Wed Nov 12 13:12:36 2025 +0000

show line error

commit a8133f3433fbdb529a9870bbfba39298fa41b4ea
Author: alex2521-code <thanakrit.tae@mahidol.ac.th>
Date: Wed Nov 12 13:11:02 2025 +0000

Added the test cases2

commit 2e8dd5b2624fe65669825fc55f9afec4aa079453
Author: alex2521-code <thanakrit.tae@mahidol.ac.th>
Date: Wed Nov 12 12:57:44 2025 +0000

Added the test cases by cmd

commit 886c30470f3b7e3119639d7b9d5c4c56e14f6e81
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Mon Nov 4 01:38:06 2024 +0000

Add one more bug

commit af8f9360d321dff40108fb6d62d07c2ab51f4413
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sat Nov 2 23:14:44 2024 +0000

Updated the code

commit 1d231767e3175bbb806dc6fef1047abc738a676a
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sat Nov 2 22:17:11 2024 +0000

Updated README.

commit c03cd9084e4e23493d52139a2ebb6d460cb5f79f
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sat Nov 2 22:13:43 2024 +0000

Removed other test cases.

commit cc20158fb48f090aa485de2cebde644737ab92bd
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sat Nov 2 22:12:24 2024 +0000

Added .gitignore

commit 4eed8f1aa1c3268b010fa7716d68341a0e242f5b
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sat Nov 2 22:12:03 2024 +0000

Added initial files.

commit 42aeda4c0e2092713331e5cb3ddaac55fb2f3db9
Author: Chaiyong Ragkhitwetsagul <cragkhit@gmail.com>
Date: Sun Nov 3 05:04:11 2024 +0700

Initial commit
51 changes: 47 additions & 4 deletions test_calculator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
# import unittest
# from calculator import Calculator

# class TestCalculator(unittest.TestCase):

# def setUp(self):
# self.calc = Calculator()

# def test_add(self):
# self.assertEqual(self.calc.add(1, 2), 3)
# self.assertEqual(self.calc.add(-1, 5), 4)

# def test_subtract(self):
# # expected a - b
# self.assertEqual(self.calc.subtract(5, 3), -2)
# self.assertEqual(self.calc.subtract(3, 5), 2)
# # Add the following test methods to the TestCalculator class:

# if __name__ == '__main__':
# unittest.main()


import unittest
from calculator import Calculator

class TestCalculator(unittest.TestCase):

def setUp(self):
self.calc = Calculator()

def test_add(self):
self.assertEqual(self.calc.add(1, 2), 3)
self.assertEqual(self.calc.add(-1, 5), 4)

def test_subtract(self):
# expected a - b
self.assertEqual(self.calc.subtract(5, 3), 2)
self.assertEqual(self.calc.subtract(3, 5), -2)

def test_multiply(self):
self.assertEqual(self.calc.multiply(2, 3), 6)
self.assertEqual(self.calc.multiply(5, 0), 0)
self.assertEqual(self.calc.multiply(0, 5), 0)

def test_divide(self):
# integer division
self.assertEqual(self.calc.divide(10, 2), 5)
self.assertEqual(self.calc.divide(9, 2), 4) # 9 // 2 == 4
self.assertEqual(self.calc.divide(0, 3), 0)
with self.assertRaises(ZeroDivisionError):
self.calc.divide(5, 0)

# Add the following test methods to the TestCalculator class:
# def test_modulo(self):
# self.assertEqual(self.calc.modulo(10, 3), 1)
# self.assertEqual(self.calc.modulo(9, 3), 0)
# self.assertEqual(self.calc.modulo(2, 5), 2)

if __name__ == '__main__':
unittest.main()
if __name__ == "__main__":
unittest.main()