Ejemplo n.º 1
0
        public void BracketPairs_Should_Generate_N_0()
        {
            BracketPairs bp = new BracketPairs();

            var results = bp.GenerateBracketPairs(0, true);

            results.Should().NotBeNull("results should not be null with n = 0 in recursive");
            results.Count.Should().Be(0, "results should have exactly 0 result with n = 0 in recursive");

            results = bp.GenerateBracketPairs(0, false);
            results.Should().NotBeNull("results should not be null with n = 0 in iterative");
            results.Count.Should().Be(0, "results should have exactly 0 result with n = 0 in iterative");
        }
Ejemplo n.º 2
0
        public void BracketPairs_Should_Generate_N_1()
        {
            BracketPairs bp = new BracketPairs();

            var results = bp.GenerateBracketPairs(1, true);

            results.Should().NotBeNull("results should not be null with n = 1 in recursive");
            results.Count.Should().Be(1, "results should have exactly 1 result with n = 1 in recursive");
            results[0].Should().Be("()", "results was not incorrect with n = 1 in recursive");

            results = bp.GenerateBracketPairs(1, false);
            results.Should().NotBeNull("results should not be null with n = 1 in iterative");
            results.Count.Should().Be(1, "results should have exactly 1 result with n = 1 in iterative");
            results[0].Should().Be("()", "results was not incorrect with n = 1 in iterative");
        }
Ejemplo n.º 3
0
        public void BracketPairs_Should_Generate_N_3()
        {
            BracketPairs bp = new BracketPairs();

            var results = bp.GenerateBracketPairs(3, true);

            results.Should().NotBeNull("results should not be null with n = 3 in recursive");
            results.Count.Should().Be(5, "results should have exactly 5 results with n = 3 in recursive");
            results.Contains("((()))").Should().BeTrue("results does not contain value ((())) with n = 3 in recursive");
            results.Contains("(())()").Should().BeTrue("results does not contain value (())() with n = 3 in recursive");
            results.Contains("()(())").Should().BeTrue("results does not contain ()(()) with n = 3 in recursive");
            results.Contains("(()())").Should().BeTrue("results does not contain value (()()) with n = 3 in recursive");
            results.Contains("()()()").Should().BeTrue("results does not contain value ()()() with n = 3 in recursive");

            results = bp.GenerateBracketPairs(3, false);
            results.Should().NotBeNull("results should not be null with n = 3 in iterative");
            results.Count.Should().Be(5, "results should have exactly 5 results with n = 3 in iterative");
            results.Contains("((()))").Should().BeTrue("results does not contain value ((())) with n = 3 in iterative");
            results.Contains("(())()").Should().BeTrue("results does not contain value (())() with n = 3 in iterative");
            results.Contains("()(())").Should().BeTrue("results does not contain ()(()) with n = 3 in iterative");
            results.Contains("(()())").Should().BeTrue("results does not contain value (()()) with n = 3 in iterative");
            results.Contains("()()()").Should().BeTrue("results does not contain value ()()() with n = 3 in iterative");
        }