public IMatch Match(string myString) { var authority = new Sequance(new Optional(new Sequance(new Userinfo(), new Character('@'))), new Host(), new Optional(new Port())); return(authority.Match(myString)); }
public IMatch Match(string myString) { IPattern method = new Choice(new Text("OPTIONS"), new Text("GET"), new Text("HEAD"), new Text("POST"), new Text("PUT"), new Text("DELETE"), new Text("TRACE"), new Text("CONNECT")); IPattern requestLine = new Sequance(method, new Text("HTTP/1.1\r")); return(requestLine.Match(myString)); }
public IMatch Match(string myString) { var uri = new Sequance(new Optional(new Scheme()), new Optional(new Text("//")), new Optional(new Authority()), new Path(), new Optional(new Sequance(new Character('?'), new Querry())), new Optional(new Sequance(new Character('#'), new Fragment()))); return(uri.Match(myString)); }
public IMatch Match(string myString) { var digit = new Range('0', '9'); var maxPort = new Sequance(new Range('6', '6'), new Range('5', '5'), new Range('0', '5'), new Range('0', '3'), new Range('0', '5')); var maxPortTwo = new Sequance(new Range('0', '6'), new Range('0', '4'), new Many(digit, 1, 4)); var port = new Sequance(new Character(':'), new Choice(maxPort, maxPortTwo, new Many(digit, 1, 4))); return(port.Match(myString)); }
public IMatch Match(string scheme) { var alpha = new Choice(new Range('a', 'z'), new Range('A', 'Z')); var schemeContent = new Sequance(alpha, new OneOrMore(new Choice(alpha, new Range('0', '9'), new Any("+-.")))); var schemeEndChar = new Character(':'); var schemeComplete = new Sequance(schemeContent, schemeEndChar); return(schemeComplete.Match(scheme)); }
public void ForabcdForabShouldReturncdForTrue() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match("abcd"); Assert.Equal("cd", actual.RemainingText()); }
public IMatch Match(string myString) { Choice alpha = new Choice(new Range('a', 'z'), new Range('A', 'Z')); Range digit = new Range('0', '9'); Choice unreserved = new Choice(alpha, digit, new Any("-._~")); Any subDelims = new Any("!$&'()*+,;="); Sequance usserInfo = new Sequance(unreserved, new Many(new Choice(unreserved, subDelims)), new Character(':')); return(usserInfo.Match(myString)); }
public void ForNullShouldReturnfalse() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match(null); Assert.False(actual.Succes()); }
public void ForNullShouldReturnNull() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match(null); Assert.Null(actual.RemainingText()); }
public void ForabcdForabShouldReturnTrue() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match("abcd"); Assert.True(actual.Succes()); }
public void ForEmptyStringShouldReturnEmptyString() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match(""); Assert.Equal("", actual.RemainingText()); }
public void ForEmptyStringShouldReturnFalse() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match(""); Assert.False(actual.Succes()); }
public void ForStringdefForabShouldReturndefWhenFalse() { var ab = new Sequance( new Character('a'), new Character('b')); IMatch actual = ab.Match("def"); Assert.Equal("def", actual.RemainingText()); }
public void TestMatch_RemainingText() { var digit = new Sequance( new Character('0'), new Character('1'), new Range('A', 'E') ); var answear = digit.Match("01AF"); Assert.Equal("F", answear.RemainingText()); }
public void For_def_For_a_b_Should_Return_False() { var ab = new Sequance( new Character('a'), new Character('b') ); IMatch actual = ab.Match("def"); Assert.False(actual.Succes()); }
public void For_String_def_For_a_b_Should_Return_def_When_False() { var ab = new Sequance( new Character('a'), new Character('b') ); IMatch actual = ab.Match("def"); Assert.Equal("def", actual.RemainingText()); }
public void ForaxStringabcCharactershoudReturnFalseAndax() { var ab = new Sequance( new Character('a'), new Character('b')); var abc = new Sequance( ab, new Character('c')); IMatch actual = abc.Match("ax"); Assert.Equal("ax", actual.RemainingText()); }
public void For_ax_String_abc_Character_shoud_Return_False_And_ax() { var ab = new Sequance( new Character('a'), new Character('b')); var abc = new Sequance( ab, new Character('c')); IMatch actual = abc.Match("ax"); Assert.Equal("ax", actual.RemainingText()); }
public void For_ax_String_abc_Character_shoud_Return_False() { var ab = new Sequance( new Character('a'), new Character('b')); var abc = new Sequance( ab, new Character('c')); IMatch actual = abc.Match("ax"); Assert.False(actual.Succes()); }
public void ForaxStringabcCharactershoudReturnFalse() { var ab = new Sequance( new Character('a'), new Character('b')); var abc = new Sequance( ab, new Character('c')); IMatch actual = abc.Match("ax"); Assert.False(actual.Succes()); }
public void TestSequanceOfCharSuccess(string text, string remaining) { var ab = new Sequance( new Charact('a'), new Charact('b') ); var abc = new Sequance( ab, new Charact('c') ); var match = abc.Match(text); Assert.True(match.Success()); Assert.Equal(remaining, match.RemainingText()); }
public void For_Null_Hex_Should_Return_Null() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match(null); Assert.Null(actual.RemainingText()); }
public void For_abc_Should_Return_abc() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match("abc"); Assert.Equal("abc", actual.RemainingText()); }
public void For_abc_Should_Return_false() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match("abc"); Assert.False(actual.Succes()); }
public void For_uB005_ab_Should_Return_true() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match("uB005 ab"); Assert.True(actual.Succes()); }
public void ForuabcdefShouldReturntrue() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match("uabcdef"); Assert.True(actual.Succes()); }
public void For_u1234_Should_Return_Empty_String() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F')); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex)); IMatch actual = hexSeq.Match("u1234"); Assert.Equal(string.Empty, actual.RemainingText()); }
public void TestSequanceWhenIsFalseAndHaveRemainingText() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F') ); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex ) ); var answear = hexSeq.Match("abc"); Assert.False(answear.Success()); }
public void TestSequanceWhenHaveManyCombinations() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F') ); var hexSeq = new Sequance( new Character('u'), new Sequance( hex, hex, hex, hex ) ); var answear = hexSeq.Match("u1234"); Assert.True(answear.Success()); }
public void TestSequanceFail(string text, string remaining) { var hex = new Choices( new Ranges('0', '9'), new Ranges('a', 'f'), new Ranges('A', 'F') ); var hexSeq = new Sequance( new Charact('u'), new Sequance( hex, hex, hex, hex ) ); var match = hexSeq.Match(text); Assert.False(match.Success()); Assert.Equal(remaining, match.RemainingText()); }