diff --git a/src/MethodCheck.Core/BinaryProcessor.cs b/src/MethodCheck.Core/BinaryProcessor.cs index 3e52efb..d683a03 100644 --- a/src/MethodCheck.Core/BinaryProcessor.cs +++ b/src/MethodCheck.Core/BinaryProcessor.cs @@ -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) diff --git a/src/MethodCheck.Test/BinaryProcessorTest.cs b/src/MethodCheck.Test/BinaryProcessorTest.cs index 68ce72f..fb521b3 100644 --- a/src/MethodCheck.Test/BinaryProcessorTest.cs +++ b/src/MethodCheck.Test/BinaryProcessorTest.cs @@ -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() {