public void ValidateExpressionTest()
        {
            TestInput[] ti =
            {
                // good expressions
                new TestInput(status.success,           "[]()(())[[()]]"),
                new TestInput(status.success,           "50 < 10043"),
                new TestInput(status.success,           "1234 > 57"),
                new TestInput(status.success,           "-1234 < 57"),
                new TestInput(status.success,           "123.4 > 57.5"),
                new TestInput(status.success,           "123.2 > 123.1"),

                // bad expressions
                new TestInput(status.invalidexpression, "(5 > 3) && (1 || 0))("),
                new TestInput(status.invalidexpression, "[(15 < 2) && (0 && 1)]]["),
                new TestInput(status.invalidexpression, "abcdeftrue")
            };

            LogicExpressionEvaluator_Accessor target = new LogicExpressionEvaluator_Accessor(); // TODO: Initialize to an appropriate value

            for (int i = 0; i < ti.Length; i++)
            {
                status retval = LogicExpressionEvaluator_Accessor.ValidateExpression(ti[i].e);
                Assert.IsTrue((ti[i].expected == retval), ti[i].e);
            }
        }
        public void PerformanceTest()
        {
            const int MAXLOOPS = 4000;

            TestInput[] ti =
            {
                new TestInput(status.istrue,  "1 && (0 || 1) && 5 > 2"),
                new TestInput(status.isfalse, "1 && (!0 || 1) && 2 > 2")
            };

            LogicExpressionEvaluator_Accessor target = new LogicExpressionEvaluator_Accessor();
            int startms = System.Environment.TickCount;

            for (int i = 0; i < ti.Length; i++)
            {
                status retStatus = status.incomplete;
                for (int loop = 0; loop < MAXLOOPS; loop++)
                {
                    retStatus = LogicExpressionEvaluator_Accessor.Evaluate(ti[i].e);
                }

                Assert.AreEqual(ti[i].expected, retStatus, ti[i].e);
            }
            int endms = System.Environment.TickCount;
            int elapsedms_evaluate = endms - startms;

            startms = System.Environment.TickCount;
            for (int i = 0; i < ti.Length; i++)
            {
                for (int loop = 0; loop < MAXLOOPS; loop++)
                {
                    LogicExpressionEvaluator_Accessor.ValidateExpression(ti[i].e);
                }
            }
            endms = System.Environment.TickCount;
            int elapsedms_validate        = endms - startms;
            int evaluations               = MAXLOOPS * ti.Length;
            int elapsedmicroseconds       = elapsedms_evaluate * 1000;
            int microsecondsperevaluation = elapsedmicroseconds / evaluations;

            // How fast is the regular expression in .NET ?
            int    js_startms = System.Environment.TickCount;
            object response   = new object();

            for (int i = 0; i < ti.Length; i++)
            {
                for (int loop = 0; loop < MAXLOOPS; loop++)
                {
                    response = LogicExpressionEvaluatorTest.EvalJScript(ti[i].e);
                }
            }
            int js_endms = System.Environment.TickCount;
            int js_elapsedms_evaluate        = js_endms - js_startms;
            int js_elapsedmicroseconds       = js_elapsedms_evaluate * 1000;
            int js_microsecondsperevaluation = js_elapsedmicroseconds / evaluations;

            string msg = string.Format("{0} ms elapsed, {1} ms for validate ({2} expressions evaluated) {3} microseconds/eval [JS {4} microseconds/eval]", elapsedms_evaluate, elapsedms_validate, evaluations, microsecondsperevaluation, js_microsecondsperevaluation);

            // we want to be at least 50% faster than the JavaScript engine (with evaluation no less!)
            int targetmicrosecondsperevaluation = microsecondsperevaluation / 2 + microsecondsperevaluation;

            Assert.IsTrue((js_microsecondsperevaluation > targetmicrosecondsperevaluation), msg);
        }