コード例 #1
0
        public void CheckForAnCorrectInput()
        {
            var oneOrMore = new OneOrMore(new Character('a'));

            Assert.True(oneOrMore.Match("abc").IsSuccesful());
            Assert.False(oneOrMore.Match("bc").IsSuccesful());
        }
コード例 #2
0
        public void TheTextNotMatchExactly()
        {
            var oneOrMore = new OneOrMore(new Text("ab"));

            Assert.False(oneOrMore.Match("acb").IsSuccesful());
            Assert.Equal("acb", oneOrMore.Match("acb").RemainingText());
        }
コード例 #3
0
        public void NotContaintTheChar()
        {
            var oneOrMore = new OneOrMore(new Character('a'));

            Assert.False(oneOrMore.Match("zx").IsSuccesful());
            Assert.Equal("zx", oneOrMore.Match("zx").RemainingText());
        }
コード例 #4
0
        public void CheckIfWorkForMoreText()
        {
            var oneOrMore = new OneOrMore(new Text("ab"));

            Assert.Equal("c", oneOrMore.Match("ababc").RemainingText());
            Assert.Equal("c", oneOrMore.Match("abababc").RemainingText());
        }
コード例 #5
0
        public void CheckForEmptyString()
        {
            var oneOrMore = new OneOrMore(new Character('a'));

            Assert.False(oneOrMore.Match("").IsSuccesful());
            Assert.Equal("", oneOrMore.Match("").RemainingText());
        }
コード例 #6
0
        public void CheckIfWorkWithMoreCharInARow()
        {
            var oneOrMore = new OneOrMore(new Character('a'));

            Assert.True(oneOrMore.Match("aabc").IsSuccesful());
            Assert.Equal("bc", oneOrMore.Match("aabc").RemainingText());
        }
コード例 #7
0
        public String()
        {
            IPattern hexadecimal      = new Sequance(new Character('u'), new Many(new Any("123456789ABCDEFabcdef"), 4, 4));
            IPattern controlChar      = new OneOrMore(new Sequance(new Character('\\'), new Choice(new Any("\"\\/bfnrt"), hexadecimal)));
            IPattern unicodeCharacter = new OneOrMore(new Choice(new Range(' ', '!'), new Range('#', '['), new Range(']', Convert.ToChar(65535))));

            stringFormat = new Sequance(new Character('\"'), new Many(new Choice(controlChar, unicodeCharacter)), new Character('\"'));
        }