Exemplo n.º 1
0
        public void CheckBalanceBrackets_correct_true_returned()
        {
            string str      = "((1+3)()(4+(3-5)))";
            bool   expected = true;

            BalanceBrackets balanceBrackets = BalanceBrackets.GetBalanceBrackets();
            bool            actual          = balanceBrackets.CheckBalanceRoundBrackets(str);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void IsBalanced_OpeningOnly_False()
        {
            var indexGenerator  = new Random(DateTime.UtcNow.Millisecond);
            var openingBrackets = new[] { '(', '[', '{' };
            var characters      = Enumerable.Range(1, 1_000_000)
                                  .Select(n => openingBrackets[indexGenerator.Next(0, 3)])
                                  .ToArray();

            var s = new string(characters);

            BalanceBrackets.IsBalanced(s).Should().BeFalse();
        }
Exemplo n.º 3
0
 public void IsBalanced_Example_MatchExpectations(string input, bool expectations)
 {
     BalanceBrackets.IsBalanced(input).Should().Be(expectations);
 }