コード例 #1
0
        public void ParseAndFormat([ValueSource(nameof(Samples))] string name)
        {
            var source = Load(name);
            var match  = Splitter.Match(source);

            Assert.That(match.Success, Is.True);

            var group = match.Groups["splitter"];
            var blob  = BinaryProcessor.Parse(source.AsSpan(0, group.Index));

            MethodData data;

            if (name.StartsWith("Body.", StringComparison.InvariantCulture))
            {
                data = MethodParser.ParseBody(blob);
            }
            else if (name.StartsWith("IL.", StringComparison.InvariantCulture))
            {
                data = MethodParser.ParseIL(blob);
            }
            else
            {
                throw new ArgumentException();
            }

            var actual   = MethodFormatter.Format(data);
            var expected = source.Substring(group.Index + group.Length);

            Assert.That(actual, Is.EqualTo(expected));
        }
コード例 #2
0
        public void ParseComments()
        {
            var blob = BinaryProcessor.Parse("42 51 0A // 05\r\n\r\n54".AsSpan());

            Assert.That(blob, Is.EqualTo(new byte[] { 0x42, 0x51, 0x0A, 0x54 }));
        }
コード例 #3
0
        public void ParseHalfByte()
        {
            var blob = BinaryProcessor.Parse("4".AsSpan());

            Assert.That(blob, Is.EqualTo(new byte[] { 0x40 }));
        }
コード例 #4
0
        public void ParseEmpty()
        {
            var blob = BinaryProcessor.Parse(string.Empty.AsSpan());

            Assert.That(blob, Is.Empty);
        }