public void TestFailure_OpenCloseOrder()
        {
            var testInput = ")) ((";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, false);
        }
        public void TestEmpty()
        {
            var testInput = "";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, true);
        }
        public void TestFailure_OpenCloseMismatch()
        {
            var testInput = "((( ))";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, false);
        }
        public void TestFailure_OnlyOpens()
        {
            var testInput = "(((";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, false);
        }
        public void TestSuccess_ManyPairs()
        {
            var testInput = "((()) () ()(())  )";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, true);
        }
        public void TestSuccess_SinglePair()
        {
            var testInput = "()";
            var isValid   = LispParentheseChecker.Validate(testInput);

            Assert.AreEqual(isValid, true);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            PrintPrompt();

            string input;

            while ((input = Console.ReadLine()).ToLower() != "quit")
            {
                var validateResult = LispParentheseChecker.Validate(input);

                var prettyResult = validateResult ? "passed" : "failed";

                Console.WriteLine($"Validation {prettyResult}.\n");

                PrintPrompt();
            }

            PrintDone();
        }