From 64f424131a773a06a7097a480b748560724c0e9a Mon Sep 17 00:00:00 2001 From: Brian Popow Date: Sat, 20 Jul 2024 19:10:27 +0200 Subject: [PATCH] Additional tests for ReadLittleEndianBytes128() --- .../Formats/Heif/Av1/Av1BitStreamTests.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1BitStreamTests.cs b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1BitStreamTests.cs index 5cfe0acace..9575864760 100644 --- a/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1BitStreamTests.cs +++ b/tests/ImageSharp.Tests/Formats/Heif/Av1/Av1BitStreamTests.cs @@ -315,6 +315,24 @@ public class Av1BitStreamTests Assert.Equal(values, actuals); } + [Theory] + [InlineData(new byte[] { 0x01 }, 1)] // One byte value. + [InlineData(new byte[] { 0x81, 0x80, 0x80, 0x00 }, 1)] // One byte value with trailing bytes. + [InlineData(new byte[] { 0xD9, 0x01 }, 217)] // Two byte value. + [InlineData(new byte[] { 0xD9, 0x81, 0x80, 0x80, 0x00 }, 217)] // Two byte value with trailing bytes. + public void ReadLittleEndianBytes128(byte[] buffer, ulong expected) + { + // arrange + Av1BitStreamReader reader = new(buffer); + + // act + ulong actual = reader.ReadLittleEndianBytes128(out int length); + + // assert + Assert.Equal(expected, actual); + Assert.NotEqual(0UL, actual); + } + [Theory] [InlineData(4, 6, 7, 9, 14)] [InlineData(8, 42, 8, 189, 63)]