public void TestAnyCharInRangeMatcher() { var m = Matcher.AnyCharInRange('a', 'z'); Assert.Equal(1, m.Match(new MatchContent("azX", 0, MatchDirection.Forward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("azX", 0, MatchDirection.Backward))); Assert.Equal(1, m.Match(new MatchContent("azX", 1, MatchDirection.Forward))); Assert.Equal(1, m.Match(new MatchContent("azX", 1, MatchDirection.Backward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("azX", 2, MatchDirection.Forward))); Assert.Equal(1, m.Match(new MatchContent("azX", 2, MatchDirection.Backward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("azX", 3, MatchDirection.Forward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("azX", 3, MatchDirection.Backward))); }
public void TestRepeatMatcher() { var m = Matcher.Repeat(Matcher.AnyCharInRange('a', 'b'), 1); Assert.Equal(2, m.Match(new MatchContent("abc", 0, MatchDirection.Forward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("abc", 0, MatchDirection.Backward))); Assert.Equal(1, m.Match(new MatchContent("abc", 1, MatchDirection.Forward))); Assert.Equal(1, m.Match(new MatchContent("abc", 1, MatchDirection.Backward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("abc", 2, MatchDirection.Forward))); Assert.Equal(2, m.Match(new MatchContent("abc", 2, MatchDirection.Backward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("abc", 3, MatchDirection.Forward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("abc", 3, MatchDirection.Backward))); Assert.Equal(Matcher.NotMatch, m.Match(new MatchContent("cba", 3, MatchDirection.Forward))); Assert.Equal(2, m.Match(new MatchContent("cba", 3, MatchDirection.Backward))); }