Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cuemon.Core/Eradicate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static bool HasMatch(int index, byte[] bytes, byte[] trailingBytes)
var match = true;
for (var i = 0; i < trailingBytes.Length; i++)
{
match &= trailingBytes[i] == bytes[index - i];
if (trailingBytes[i] != bytes[index - i]) { match = false; }
}
return match;
}
Expand Down
10 changes: 10 additions & 0 deletions test/Cuemon.Core.Tests/EradicateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ public void TrailingBytes_WithRepeatedTrailingPattern_RemovesAllTrailingPatterns
Assert.Equal(new byte[] { 1, 2 }, sut);
}

[Theory]
[InlineData(new byte[] { 1, 2, 3 }, new byte[] { 1, 2 })]
[InlineData(new byte[] { 1, 2, 4 }, new byte[] { 1, 2, 4 })]
public void TrailingBytes_ShouldReturnExpectedBytes_WhenTrailingByteMatchesOrDiffers(byte[] bytes, byte[] expected)
{
var sut = Eradicate.TrailingBytes(bytes, new byte[] { 3 });

Assert.Equal(expected, sut);
}

[Fact]
public void TrailingBytes_WithoutTrailingPattern_ReturnsSameInstance()
{
Expand Down
Loading