public void MuplipleTextMatch() { var a = new Many(new Character('a')); Assert.True(a.Match("aaaabcd").Success()); Assert.Equal("bcd", a.Match("aaaabcd").RemainingText()); }
public void IsInRange() { var digits = new Many(new Json.Range('0', '9')); Assert.True(digits.Match("12345ab123").Success()); Assert.Equal("ab123", digits.Match("12345ab123").RemainingText()); }
public void TextMatchesManyTextPattern() { Many pattern = new Many(new Text("abc")); Assert.True(pattern.Match("abcabcd").Success()); Assert.True(pattern.Match("abcabcd").RemainingText() == "d"); }
public void TextEmptyReturnTrue() { var a = new Many(new Character('a')); Assert.True(a.Match("").Success()); Assert.Equal("", a.Match("").RemainingText()); }
public void TextNullReturnTrue() { var a = new Many(new Character('a')); Assert.True(a.Match(null).Success()); Assert.Null(a.Match(null).RemainingText());; }
public void NullMatchesManyDigitRange() { Many pattern = new Many(new Range('0', '9')); Assert.True(pattern.Match(null).Success()); Assert.True(pattern.Match(null).RemainingText() == null); }
public void FirstCharMatchesManyDigitsPattern() { Many pattern = new Many(new Range('0', '9')); Assert.True(pattern.Match("ab").Success()); Assert.True(pattern.Match("ab").RemainingText() == "ab"); }
public void NullMatchesManyCharPattern() { Many pattern = new Many(new Character('a')); Assert.True(pattern.Match(null).Success()); Assert.True(pattern.Match(null).RemainingText() == null); }
public void FirstNumberMatchManyDigitsPattern() { Many pattern = new Many(new Range('0', '9')); Assert.True(pattern.Match("12345ab123").Success()); Assert.True(pattern.Match("12345ab123").RemainingText() == "ab123"); }
public void EmptyStringDoesNotMatchCharacter() { Many pattern = new Many(new Character('a')); Assert.True(pattern.Match("").Success()); Assert.True(pattern.Match("").RemainingText() == ""); }
public void EmptyMatchesManyCharacterPattern() { Many pattern = new Many(new Character('a')); Assert.True(pattern.Match("").Success()); Assert.True(pattern.Match("").RemainingText()?.Length == 0); }
public void ReturnsTrueAndTextForNoMatchesRange() { var digits = new Many(new Range('0', '9')); Assert.True(digits.Match("ab").Success()); Assert.Equal("ab", digits.Match("ab").RemainingText()); }
public void FirstCharacterMatchesManyCharPattern() { Many pattern = new Many(new Character('a')); Assert.True(pattern.Match("abc").Success()); Assert.True(pattern.Match("abc").RemainingText() == "bc"); }
public void ReturnsTrueAndRemainingForMatches() { var digits = new Many(new Range('0', '9')); Assert.True(digits.Match("12345ab123").Success()); Assert.Equal("ab123", digits.Match("12345ab123").RemainingText()); }
public void ReturnsFalseAndEmptyForEmptyString() { var a = new Many( new Character('a')); Assert.True(a.Match("").Success()); Assert.Equal("", a.Match("").RemainingText()); }
public void ReturnsTrueEndTextForNoMatches() { var a = new Many( new Character('a')); Assert.True(a.Match("bc").Success()); Assert.Equal("bc", a.Match("bc").RemainingText()); }
public void StringAsParamReturnsCorectFormatForString() { var seqence = new Sequence(new Character('a'), new Character('b')); var digits = new Many(seqence); Assert.Equal("ac", digits.Match("ababac").RemainingText()); }
public void ForIPatternCharaAndStringabcShouldReturnTrue() { var a = new Many(new Character('a')); IMatch actual = a.Match("abc"); Assert.True(actual.Succes()); }
public void ForIPatternRange09AndString12345ab123ShouldReturnab123() { var digits = new Many(new Range('0', '9')); IMatch actual = digits.Match("12345ab123"); Assert.Equal("ab123", actual.RemainingText()); }
public void For_IPattern_Char_a_And_String_bc_Should_Return_String_bc() { var a = new Many(new Character('a')); IMatch actual = a.Match("bc"); Assert.Equal("bc", actual.RemainingText()); }
public void Should_Return__Correct_String_Hexadecimal_Sequence() { var hex = new Choice( new Range('0', '9'), new Range('a', 'f'), new Range('A', 'F') ); var hexSeq = new Sequence( new Character('u'), new Sequence( hex, hex, hex, hex ) ); var pattern = new Many( new Sequence(hexSeq) ); var match = pattern.Match("u1234u1234u12Zabc"); Assert.Equal("u12Zabc", match.RemainingText()); Assert.True(match.Success()); }
public void For_IPattern_Char_a_And_String_EmptyString_Should_Return_True() { var a = new Many(new Character('a')); IMatch actual = a.Match(string.Empty); Assert.True(actual.Succes()); }
public void ForIPatternRange09AndStringabShouldReturnTrue() { var digits = new Many(new Range('0', '9')); IMatch actual = digits.Match("ab"); Assert.True(actual.Succes()); }
public void StringAsParamReturnsTrueForString() { var seqence = new Sequence(new Character('a'), new Character('b')); var digits = new Many(seqence); Assert.True(digits.Match("ababc").Success()); }
public void For_IPattern_Range_0_9_And_String_12345ab123_Should_Return_True() { var digits = new Many(new Range('0', '9')); IMatch actual = digits.Match("12345ab123"); Assert.True(actual.Succes()); }
public void For_IPattern_Char_a_And_String_EmptyString_Should_Return_String_EmptyString() { var a = new Many(new Character('a')); IMatch actual = a.Match(string.Empty); Assert.Equal(string.Empty, actual.RemainingText()); }
public void ForIPatternCharaAndStringEmptyStringShouldReturnStringEmptyString() { var a = new Many(new Character('a')); IMatch actual = a.Match(string.Empty); Assert.Equal(string.Empty, actual.RemainingText()); }
public void For_IPattern_Range_0_9_And_String_12345ab123_Should_Return_ab123() { var digits = new Many(new Range('0', '9')); IMatch actual = digits.Match("12345ab123"); Assert.Equal("ab123", actual.RemainingText()); }
public void ForIPatternCharaAndStringbcShouldReturnStringbc() { var a = new Many(new Character('a')); IMatch actual = a.Match("bc"); Assert.Equal("bc", actual.RemainingText()); }
public IMatch Match(string text) { IMatch match = element.Match(text); return(match.Success() ? list.Match(match.RemainingText()) : new SuccessMatch(match.RemainingText())); }