forked from AJMitev/FileTypeChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve abstraction by introducing MagicSequenace to wrap magic bytes…
… logic. Add support for Webp. Refactor example apps
- Loading branch information
ajmitev
committed
Oct 29, 2022
1 parent
f446318
commit 82f6bf0
Showing
29 changed files
with
307 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace FileTypeChecker.Tests | ||
{ | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class MagicSequenceTests | ||
{ | ||
[Test] | ||
[TestCase(new byte[] { 0x49, 0x44, 0x33 }, new byte[] { 0x49, 0x44, 0x33 }, 3)] | ||
[TestCase(new byte[] { 0x49, 0x44, 0x33, 0x44 }, new byte[] { 0x49, 0x44, 0x33 }, 3)] | ||
[TestCase(new byte[] { 0x49, 0x44, 0x33, 0x44 }, new byte[] { 0x44, 0x49, 0x44, 0x33 }, 0)] | ||
[TestCase(new byte[] { 0x44, 0x49, 0x44, 0x33, 0x44 }, new byte[] { 0x49, 0x44, 0x33 }, 0)] | ||
public void CountMatchingBytesShouldReturnNumbersOfMachtingBytes(byte[] magicBytes, byte[] compareBytes, int matching) | ||
{ | ||
var sequence = new MagicSequence(magicBytes); | ||
var actual = sequence.CountMatchingBytes(compareBytes); | ||
|
||
Assert.AreEqual(matching, actual); | ||
} | ||
|
||
[Test] | ||
[TestCase(new byte[] { 0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38 }, new byte[] { 0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38 }, 11, 4, 5)] | ||
public void CountMatchingBytesShouldReturnNumbersOfMachtingBytesWhenThereIsSkipInTheMiddle(byte[] magicBytes, byte[] compareBytes, int matching, int bytesToSkip, int startFrom) | ||
{ | ||
var sequence = new MagicSequence(magicBytes, bytesToSkip, startFrom); | ||
var actual = sequence.CountMatchingBytes(compareBytes); | ||
|
||
Assert.AreEqual(matching, actual); | ||
} | ||
|
||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.