-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_parenthetics.py
55 lines (29 loc) · 1 KB
/
test_parenthetics.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
from parenthetics import is_balanced
import pytest
# These are unit tests for the parenthetics.py file
def test_isone():
assert is_balanced("(") == 1
def test_isneg():
assert is_balanced(")") == -1
def test_iszero():
assert is_balanced("( )") == 0
def test_withstring():
assert is_balanced("this is a (string) with open and close") == 0
def test_mismatched():
assert is_balanced("This is a string with )))))(((((( wrong order") == -1
def test_bug():
assert is_balanced("()(") == 1
def test_greater_than_one():
assert is_balanced("(((") == 1
def test_three():
assert is_balanced("(((this is some text)))some more text") == 0
def test_three_unballanced():
assert is_balanced("(((text))))(") == -1
def test_empty():
assert is_balanced("") == 0
def test_no_paren():
assert is_balanced("this is text no parenthesis") == 0
def test_jumbled_up():
assert is_balanced("(()()))()") == -1
def test_will_it_break():
assert is_balanced("()())(())(())(((") == -1