Esempio n. 1
0
        public void LEFT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("LEFT('123222',3)", "");

            Assert.AreEqual(t, "123");
        }
Esempio n. 2
0
        public void abs_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("abs(-1.2)", 0.0);

            Assert.AreEqual(1.2, t);
        }
Esempio n. 3
0
        public void VALUE_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("VALUE(\"123\")", 0);

            Assert.AreEqual(t, 123);
        }
Esempio n. 4
0
        public void Pi_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("pi()", 0.0);

            Assert.AreEqual(3.141592654, Math.Round(t, 9));
        }
Esempio n. 5
0
        public void degrees_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("degrees(pi())", 0.0);

            Assert.AreEqual(180.0, t);
        }
Esempio n. 6
0
        public void CONCATENATE_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("CONCATENATE('tt','33')", "");

            Assert.AreEqual(t, "tt33");
        }
Esempio n. 7
0
        public void LCM_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("LCM(3,5,7)", 0.0);

            Assert.AreEqual(105.0, t);
        }
Esempio n. 8
0
        public void REPT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("REPT(\"q\",3)", "");

            Assert.AreEqual(t, "qqq");
        }
Esempio n. 9
0
        public void RIGHT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("RIGHT(\"123q\",3)", "");

            Assert.AreEqual(t, "23q");
        }
Esempio n. 10
0
        public void MID_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("MID('ABCDEF',2,3)", "");

            Assert.AreEqual(t, "BCD");
        }
Esempio n. 11
0
        public void PROPER_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("PROPER('abc abc')", "");

            Assert.AreEqual(t, "Abc Abc");
        }
Esempio n. 12
0
        public void LOWER_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("LOWER('ABC')", "");

            Assert.AreEqual(t, "abc");
        }
Esempio n. 13
0
        public void ASC_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("asc('abcABC123')", "");

            Assert.AreEqual(t, "abcABC123");
        }
Esempio n. 14
0
        public void LEN_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("LEN('123222')", 0);

            Assert.AreEqual(t, 6);
        }
Esempio n. 15
0
        public void CLEAN_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("clean('\\r112\\t')", "");

            Assert.AreEqual(t, "112");
        }
Esempio n. 16
0
        public void RMB_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("rmb(12.3)", "");

            Assert.AreEqual(t, "壹拾贰元叁角");
        }
Esempio n. 17
0
        public void code_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("code('1')", 0);

            Assert.AreEqual(t, 49);
        }
Esempio n. 18
0
        public void SEARCH_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("SEARCH(\"aa\",\"abbAaddd\")", 0);

            Assert.AreEqual(t, 4);
        }
Esempio n. 19
0
        public void FIND_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("FIND(\"11\",\"12221122\")", 0);

            Assert.AreEqual(t, 5);
        }
Esempio n. 20
0
        public void TEXT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("TEXT(123,\"0.00\")", "");

            Assert.AreEqual(t, "123.00");
        }
Esempio n. 21
0
        public void combin_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("combin(10,2)", 0.0);

            Assert.AreEqual(45.0, t);
        }
Esempio n. 22
0
        public void TRIM_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("TRIM(\" 123 123 \")", "");

            Assert.AreEqual(t, "123 123");
        }
Esempio n. 23
0
        public void PERMUT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("PERMUT(10,2)", 0.0);

            Assert.AreEqual(90.0, t);
        }
Esempio n. 24
0
        public void UPPER_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("UPPER(\"abc\")", "");

            Assert.AreEqual(t, "ABC");
        }
Esempio n. 25
0
        public void RADIANS_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("RADIANS(180)", 0.0);

            Assert.AreEqual(Math.PI, t);
        }
Esempio n. 26
0
        public void CHAR_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("char(49)", "");

            Assert.AreEqual(t, "1");
        }
Esempio n. 27
0
        public void Test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            double          t      = 0.0;

            if (engine.Parse("1+2"))
            {
                t = (double)engine.Evaluate();
            }
            Assert.AreEqual(3.0, t);

            var c = engine.TryEvaluate("2+3", 0);

            Assert.AreEqual(5, c);

            var e = engine.TryEvaluate("e", 0.0);

            Assert.AreEqual(Math.E, e);
            e = engine.TryEvaluate("pi", 0.0);
            Assert.AreEqual(Math.PI, e);

            var b = engine.TryEvaluate("true", true);

            Assert.AreEqual(true, b);
            b = engine.TryEvaluate("false", false);
            Assert.AreEqual(false, b);

            var b1 = engine.TryEvaluate("if(true,1,2)", 0);

            Assert.AreEqual(1, b1);

            b1 = engine.TryEvaluate("if(false,1,2)", 0);
            Assert.AreEqual(2, b1);

            var b2 = engine.TryEvaluate("pi*4", 0.0);

            Assert.AreEqual(Math.PI * 4, b2);
            b2 = engine.TryEvaluate("e*4", 0.0);
            Assert.AreEqual(Math.E * 4, b2);

            var s = engine.TryEvaluate("'aa'&'bb'", "");

            Assert.AreEqual("aabb", s);

            var r = engine.TryEvaluate("count({ 1,2,3,4})", 0);

            Assert.AreEqual(4, r);


            r = engine.TryEvaluate("(1=1)*9+2", 0);
            Assert.AreEqual(11, r);;
            r = engine.TryEvaluate("(1=2)*9+2", 0);
            Assert.AreEqual(2, r);;

            var dt = engine.TryEvaluate("'2016-1-1'+1", DateTime.MinValue);

            Assert.AreEqual(DateTime.Parse("2016-1-2"), dt);;
            dt = engine.TryEvaluate("'2016-1-1'+9*'1:0'", DateTime.MinValue);
            Assert.AreEqual(DateTime.Parse("2016-1-1 9:0"), dt);;
        }
        public void SQRTPI_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("SQRTPI(3)", 0.0);

            t = Math.Round(t, 6);
            Assert.AreEqual(Math.Round(3.069980124, 6), t);
        }
        public void SUMSQ_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("SUMSQ(1,2)", 0.0);

            t = Math.Round(t, 6);
            Assert.AreEqual(Math.Round(5.0, 6), t);
        }
        public void PRODUCT_test()
        {
            AlgorithmEngine engine = new AlgorithmEngine();
            var             t      = engine.TryEvaluate("PRODUCT(1,2,3,4)", 0.0);

            t = Math.Round(t, 6);
            Assert.AreEqual(Math.Round(24.0, 6), t);
        }