예제 #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('\"'));
        }