EnsureFixedContents: derive length from expected, not pass it as argument

This commit is contained in:
Mikhail Yakshin 2016-11-22 14:01:26 +03:00
parent 07063813c1
commit 923e9c9fc3
1 changed files with 2 additions and 3 deletions

View File

@ -317,12 +317,11 @@ namespace Kaitai
/// <summary>
/// Read a specific set of bytes and assert that they are the same as an expected result
/// </summary>
/// <param name="length">The number of bytes to read</param>
/// <param name="expected">The expected result</param>
/// <returns></returns>
public byte[] EnsureFixedContents(int length, byte[] expected)
public byte[] EnsureFixedContents(byte[] expected)
{
var bytes = ReadBytes(length);
var bytes = ReadBytes(expected.Length);
if (!bytes.SequenceEqual(expected))
{
throw new Exception($"Expected bytes: {Convert.ToBase64String(expected)}, Instead got: {Convert.ToBase64String(bytes)}");