Skip to content

Commit

Permalink
Merge pull request #15 from InfiniteEnergy/allow-suffix
Browse files Browse the repository at this point in the history
add `StringRightStartsWithLeft` matcher
  • Loading branch information
ryepup authored Apr 15, 2021
2 parents 4f459e9 + 6c99b8f commit a7df5aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/XlsxCompare.Tests/MatchByTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class MatchByTests
[DataRow(MatchBy.StringLeftStartsWithRight, "asdf", "as")]
[DataRow(MatchBy.Decimal, "0.084400", "0.0844")]
[DataRow(MatchBy.Decimal, "0.00", "0")]
[DataRow(MatchBy.StringRightStartsWithLeft, "asdf", "asdf and then some")]
public void IsMatch_ThingsThatMatch_ReturnsTrue(MatchBy? match, string left, string right)
{
Assert.IsTrue(match.IsMatch(left, right));
Expand All @@ -34,6 +35,8 @@ public void IsMatch_ThingsThatMatch_ReturnsTrue(MatchBy? match, string left, str
[DataRow(MatchBy.StringLeftStartsWithRight, "as", "asdf")]
[DataRow(MatchBy.StringLeftStartsWithRight, "asdf", "")]
[DataRow(MatchBy.Decimal, "0.084400", "0.0845")]
[DataRow(MatchBy.StringRightStartsWithLeft, "", "asdf and then some")]
[DataRow(MatchBy.StringRightStartsWithLeft, "asdf but no", "asdf and then some")]
public void IsMatch_ThingsThatDoNotMatch_ReturnsFalse(MatchBy? match, string left, string right)
{
Assert.IsFalse(match.IsMatch(left, right));
Expand Down
2 changes: 2 additions & 0 deletions src/XlsxCompare/MatchBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public enum MatchBy
Decimal,
Date,
StringLeftStartsWithRight,
StringRightStartsWithLeft,
}

static class MatchByExtensions
Expand All @@ -22,6 +23,7 @@ public static bool IsMatch(this MatchBy? match, string left, string right)
MatchBy.Integer => IsIntegerMatch(left, right),
MatchBy.StringIgnoreMissingLeft => left.Length == 0 || IsStringMatch(left, right),
MatchBy.StringLeftStartsWithRight => IsLeftStartsWithRightMatch(left, right),
MatchBy.StringRightStartsWithLeft => IsLeftStartsWithRightMatch(right, left),
MatchBy.Decimal => IsDecimalMatch(left, right),
_ => IsStringMatch(left, right),
};
Expand Down

0 comments on commit a7df5aa

Please sign in to comment.