-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
66 lines (59 loc) · 1.55 KB
/
test.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
66
"""Aqui se ejecutan todas la pruebas para validar que pase el ejercicio
"""
# TODO: add test completly
import pytest
from unittest import TestCase
# import functions interviews
from .find_contacts import contacts
from .brackets import isBalanced
from .median import runningMedian
from .substring import Solution
def test_find_contacts():
"""
Create a test case for find_contacts
"""
queries = ['add hack', 'add hackerrank', 'find hac', 'find hak']
result = contacts(queries)
print(result)
assert int(result) == 2
def test_isBalanced():
data = "{][({(}]][[[{}]][[[())}[)(]([[[)][[))[}[]][()}))](]){}}})}[{]{}{((}]}{{)[{[){{)[]]}))]()]})))["
result_balance = isBalanced(data)
print(result_balance)
assert result_balance == "NO"
def test_runningMedian():
"""
Create a test case for runningMedian
"""
a = [7, 3, 5, 2, 4, 6, 8]
result = runningMedian(a)
print(result)
assert result == 2
@pytest.mark.parametrize(
"substring,expected",
[
("abcabcbb",3),
("bbbbb",1),
("pwwkew",3),
("",0),
("a",1),
("au",2),
("dvdf",3),
]
)
def test_substring(substring, expected):
"""
Create a test case for substring
"""
s = Solution()
string_one = s.lengthOfLongestSubstring(substring)
print(substring, ": ", string_one)
assert int(string_one) == expected
@pytest.mark.parametrize(
"array_one,array_two,expected",
[
([1,2],[3,4],2.5),
]
)
def test_median_two_array(array_one,array_two,expected):
assert 2.5 == 2.5