forked from Mattie/cataclysm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_doom_basics.py
65 lines (50 loc) · 1.71 KB
/
test_doom_basics.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pytest
from cataclysm import doom
# TODO Add a setup to clear the code cache
def test_add_numbers():
# Positive test
result = doom.add_numbers(5, 7)
assert result == 12
# Negative test, to ensure it's not always returning the same thing
result = doom.add_numbers(-5, 7)
assert result != 12
def test_multiply_numbers():
# Positive test
result = doom.multiply_numbers(3, 4)
assert result == 12
# Negative test, to ensure it's not always doing the same thing
result = doom.multiply_numbers(3, 1)
assert result != 12
def test_string_to_upper():
# Positive test
result = doom.string_to_upper("hello world")
assert result == "HELLO WORLD"
# Negative test, to ensure it's not always returning the same thing
result = doom.string_to_upper("hello worlds")
assert result != "HELLO WORLD"
def test_list_length():
# Positive test
result = doom.list_length([1, 2, 3, 4, 5])
assert result == 5
# Negative test, to ensure it's not always returning the same thing
result = doom.list_length(['hello'])
assert result != 5
def test_is_even():
# Positive test
result = doom.is_even(10)
assert result == True
# Positive test for odd number
result = doom.is_even(7)
assert result == False
# Negative test for odd number
result = doom.is_even(9)
assert result != True
def test_sum_of_squares():
# Test if doom can generate a function to calculate the sum of squares of a list of numbers
# Positive test
result = doom.sum_of_squares([1, 2, 3])
assert result == 14
# Negative test
result = doom.sum_of_squares([2, 2, 3])
assert result != 14
# To run tests, execute the command `pytest <filename>.py`