Beispiel #1
0
        private static void BalancedBracketsTest()
        {
            string input = "([])[]({})";

            input = "((()))";
            WriteLine($"{input} is balanced: {BalancedBrackets.IsBalanced(input)}");
        }
Beispiel #2
0
        public void Should_print_yes_when_brackets_are_balanced()
        {
            var brackets = new[] { "{}", "[]", "()", "{[()]}", "{{[[(())]]}}" };
            var sut      = new BalancedBrackets();

            foreach (var bracket in brackets)
            {
                var isBalanced = sut.IsBalanced(bracket);
                Assert.True(isBalanced);
            }
        }
        public void Test()
        {
            // Arrange
            var brackets = "{[()]}";
            var bb       = new BalancedBrackets();

            // Act
            var isBalanced = bb.IsBalanced(brackets);

            // Assert
            Assert.Equal("YES", isBalanced);
        }
        public void BracketsAreNotBalanced2()
        {
            // Arrange
            var brackets = "{(([])[])[]]}";
            var bb       = new BalancedBrackets();

            // Act
            var isBalanced = bb.IsBalanced(brackets);

            // Assert
            Assert.Equal("NO", isBalanced);
        }
Beispiel #5
0
        public void Should_print_false_when_brackets_are_unbalanced()
        {
            var brackets = new[] { "}}", "(", "[[", "]]", "((", "))", "{]", "{)", "(}", "(]", "[)", "[}", "{[(])}", "{[{[(())]]}}", "{{[[(())]}}" };

            var sut = new BalancedBrackets();

            foreach (var bracket in brackets)
            {
                var isBalanced = sut.IsBalanced(bracket);
                Assert.False(isBalanced);
            }
        }