Skip to content

Commit

Permalink
Add lossless encode test which checks the expected bytes count of the…
Browse files Browse the repository at this point in the history
… encoded file
  • Loading branch information
brianpopow committed Dec 4, 2021
1 parent 72c6f52 commit 3780ca7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/ImageSharp.Tests/Formats/WebP/WebpEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ public void Encode_Lossless_WithDifferentMethodAndQuality_Works<TPixel>(TestImag
image.VerifyEncoder(provider, "webp", testOutputDetails, encoder);
}

[Theory]
[WithFile(Lossy.NoFilter06, PixelTypes.Rgba32, 15114)]
public void Encode_Lossless_WithBestQuality_HasExpectedSize<TPixel>(TestImageProvider<TPixel> provider, int expectedBytes)
where TPixel : unmanaged, IPixel<TPixel>
{
var encoder = new WebpEncoder()
{
FileFormat = WebpFileFormatType.Lossless,
Method = WebpEncodingMethod.BestQuality
};

using Image<TPixel> image = provider.GetImage();
using var memoryStream = new MemoryStream();
image.Save(memoryStream, encoder);

Assert.Equal(memoryStream.Length, expectedBytes);
}

[Theory]
[WithFile(RgbTestPattern100x100, PixelTypes.Rgba32, 85)]
[WithFile(RgbTestPattern100x100, PixelTypes.Rgba32, 60)]
Expand Down

0 comments on commit 3780ca7

Please sign in to comment.