示例#1
0
        public void GetNumber()
        {
            var tp = new TestParser();

            tp.SetContext("  1 1.5/*test*/.5 0.123 1234 -.5 -12 . ", 0);
            tp.ExpectNumber("1");
            tp.ExpectNumber("1.5");
            tp.ExpectNumber("0.5");
            tp.ExpectNumber("0.123");
            tp.ExpectNumber("1234");
            tp.ExpectNumber("-0.5");
            tp.ExpectNumber("-12");
            tp.ExpectNumber(null);

            tp = new TestParser();
            tp.SetContext("-", 0);
            tp.ExpectNumber(null);

            tp = new TestParser();
            tp.SetContext("12.5.1", 0);
            tp.ExpectNumber("12.5");

            tp = new TestParser();
            tp.SetContext("-x", 0);
            tp.ExpectNumber(null);
            tp.ExpectName("-x");
        }