Last active
August 29, 2015 14:11
-
-
Save neoneo40/9b79cd16b7d5de65a625 to your computer and use it in GitHub Desktop.
Test Brackets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from brackets import well_matched | |
class TestBrackets(unittest.TestCase): | |
def testBrackets(self): | |
s = '''()() | |
({[}]) | |
({}[(){}]) | |
) | |
} | |
}}} | |
{}[]() | |
{[([()])]} | |
{[([()])]''' | |
problems = s.split('\n') | |
# answers = [True, False, True, False, False, False, True, True, False] | |
answers = ['YES', 'NO', 'YES', 'NO', 'NO', 'NO', 'YES', 'YES', 'NO'] | |
d = {} | |
for k, v in zip(problems, answers): | |
d[k] = v | |
for k, v in d.items(): | |
test_answer = well_matched(k) | |
self.assertEqual(test_answer, v) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment