Skip to content

Commit 05f672d

Browse files
author
abregman
committed
Add more exercises
1 parent 5830168 commit 05f672d

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
|--------|--------|------|----|
1414
| Calculator | [Exercise](exercises/functions/calculator.md) | [Solution](solutions/functions/calculator.md) | |
1515

16+
## Unit Testing
17+
18+
|Name|Objective & Instructions|Solution|Comments|
19+
|--------|--------|------|----|
20+
| Calculator Unit Tests | [Exercise](exercises/unit_testing/calculator.md) | [Solution](solutions/unit_testing/calculator.md) | |
21+
| Fix Calculator Unit Tests | [Exercise](exercises/unit_testing/fix_calculator_tests.md) | | |
22+
1623
## Exceptions
1724

1825
|Name|Objective & Instructions|Solution|Comments|

exercises/exceptions/divide_by_zero.md

Whitespace-only changes.

exercises/unit_testing/calculator.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Calculator - Unit Tests
2+
3+
Write unit tests for the following functions
4+
5+
```python
6+
def add(x, y):
7+
"""Add numbers"""
8+
return x + y
9+
10+
def substract(x, y):
11+
"""Substract numbers"""
12+
return x - y
13+
14+
def multiply(x, y):
15+
"""Multiply numbers"""
16+
17+
def divide(x, y):
18+
"""Divide numbers"""
19+
if y == 0:
20+
raise ValueError('Can not divide by zero!')
21+
return x / y
22+
```
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Fix Calculator Tests
2+
3+
Fix the following Python test file to run successfully the tests
4+
5+
```python
6+
import unittest
7+
import calc
8+
9+
class TestCalculator(unittest.TestCase):
10+
11+
def add_test(self):
12+
self.assertEqual(calculator.add(1, 1), 2)
13+
14+
15+
def test_substract():
16+
self.assertEqual(calculator.substract(4, 3), 1)
17+
```

0 commit comments

Comments
 (0)