Sha256: ab5b319e002eef06a5e1c0e9e946785db6c54ea7b230b746fd739494311c2c25

Contents?: true

Size: 1.76 KB

Versions: 62

Compression:

Stored size: 1.76 KB

Contents

import unittest

from bracket_push import check_brackets


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.1.0

class BracketPushTests(unittest.TestCase):
    def test_paired_square_brackets(self):
        self.assertEqual(check_brackets("[]"), True)

    def test_empty_string(self):
        self.assertEqual(check_brackets(""), True)

    def test_unpaired_brackets(self):
        self.assertEqual(check_brackets("[["), False)

    def test_wrong_ordered_brackets(self):
        self.assertEqual(check_brackets("}{"), False)

    def test_wrong_closing_bracket(self):
        self.assertEqual(check_brackets("{]"), False)

    def test_paired_with_whitespace(self):
        self.assertEqual(check_brackets("{ }"), True)

    def test_simple_nested_brackets(self):
        self.assertEqual(check_brackets("{[]}"), True)

    def test_several_paired_brackets(self):
        self.assertEqual(check_brackets("{}[]"), True)

    def test_paired_and_nested_brackets(self):
        self.assertEqual(check_brackets("([{}({}[])])"), True)

    def test_unopened_closing_brackets(self):
        self.assertEqual(check_brackets("{[)][]}"), False)

    def test_unpaired_and_nested_brackets(self):
        self.assertEqual(check_brackets("([{])"), False)

    def test_paired_and_wrong_nested_brackets(self):
        self.assertEqual(check_brackets("[({]})"), False)

    def test_math_expression(self):
        self.assertEqual(
            check_brackets("(((185 + 223.85) * 15) - 543)/2"), True)

    def test_complex_latex_expression(self):
        self.assertEqual(
            check_brackets(
                ("\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{"
                 "x} &... x^2 \\end{array}\\right)")), True)


if __name__ == '__main__':
    unittest.main()

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
trackler-2.2.1.107 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.106 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.105 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.104 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.103 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.102 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.101 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.100 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.99 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.98 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.97 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.96 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.95 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.94 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.93 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.92 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.91 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.90 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.89 tracks/python/exercises/bracket-push/bracket_push_test.py
trackler-2.2.1.88 tracks/python/exercises/bracket-push/bracket_push_test.py