Skip to content
Merged
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
29 changes: 16 additions & 13 deletions src/MethodCheck.Core/BinaryProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,28 @@ public static class BinaryProcessor
continue;
}

c |= '\x20';

if ((uint)(c - '0') <= 9)
{
x = unchecked((byte)(c - '0'));
}
else if ((uint)(c - 'a') <= 6)
{
x = unchecked((byte)(c - 'a' + 10));
}
else if (c == '/' && index < text.Length && text[index] == '/')
{
readingComment = true;
index++;
continue;
}
else
{
return null;
c |= '\x20';

if ((uint)(c - 'a') <= 5)
{
x = unchecked((byte)(c - 'a' + 10));
}
else if (c == '/' && index < text.Length && text[index] == '/')
{
readingComment = true;
index++;
continue;
}
else
{
return null;
}
}

if (halfByte)
Expand Down
8 changes: 8 additions & 0 deletions src/MethodCheck.Test/BinaryProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ namespace MethodCheck.Test
[TestFixture]
class BinaryProcessorTest
{
[TestCase("42 = 67")]
[TestCase("01 G0")]
[TestCase("0\u0011", TestName = "{m}(controlChar)")]
public void ParseInvalid(string text)
{
Assert.That(BinaryProcessor.Parse(text), Is.Null);
}

[Test]
public void ParseEmpty()
{
Expand Down