Skip to content

Commit

Permalink
Add more exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Feb 27, 2022
1 parent 5830168 commit 05f672d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
|--------|--------|------|----|
| Calculator | [Exercise](exercises/functions/calculator.md) | [Solution](solutions/functions/calculator.md) | |

## Unit Testing

|Name|Objective & Instructions|Solution|Comments|
|--------|--------|------|----|
| Calculator Unit Tests | [Exercise](exercises/unit_testing/calculator.md) | [Solution](solutions/unit_testing/calculator.md) | |
| Fix Calculator Unit Tests | [Exercise](exercises/unit_testing/fix_calculator_tests.md) | | |

## Exceptions

|Name|Objective & Instructions|Solution|Comments|
Expand Down
Empty file.
22 changes: 22 additions & 0 deletions exercises/unit_testing/calculator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Calculator - Unit Tests

Write unit tests for the following functions

```python
def add(x, y):
"""Add numbers"""
return x + y

def substract(x, y):
"""Substract numbers"""
return x - y

def multiply(x, y):
"""Multiply numbers"""

def divide(x, y):
"""Divide numbers"""
if y == 0:
raise ValueError('Can not divide by zero!')
return x / y
```
17 changes: 17 additions & 0 deletions exercises/unit_testing/fix_calculator_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Fix Calculator Tests

Fix the following Python test file to run successfully the tests

```python
import unittest
import calc

class TestCalculator(unittest.TestCase):

def add_test(self):
self.assertEqual(calculator.add(1, 1), 2)


def test_substract():
self.assertEqual(calculator.substract(4, 3), 1)
```

0 comments on commit 05f672d

Please sign in to comment.