Skip to content

Commit d1c6e50

Browse files
author
Dmitry Pentin
committed
Added test image
1 parent 55d01f2 commit d1c6e50

File tree

5 files changed

+39
-1
lines changed

5 files changed

+39
-1
lines changed

tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Images.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public partial class JpegDecoderTests
3333
TestImages.Jpeg.Issues.ExifGetString750Load,
3434
TestImages.Jpeg.Issues.ExifGetString750Transform,
3535
TestImages.Jpeg.Issues.BadSubSampling1076,
36+
TestImages.Jpeg.Issues.ValidExifArgumentNullExceptionOnEncode,
3637

3738
// LibJpeg can open this despite the invalid density units.
3839
TestImages.Jpeg.Issues.Fuzz.ArgumentOutOfRangeException825B,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System;
5+
using System.IO;
6+
using SixLabors.ImageSharp.Formats.Jpeg;
7+
using SixLabors.ImageSharp.PixelFormats;
8+
9+
using Xunit;
10+
11+
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
12+
{
13+
[Trait("Format", "Jpg")]
14+
public partial class JpegEncoderTests
15+
{
16+
[Theory]
17+
[WithFile(TestImages.Jpeg.Issues.ValidExifArgumentNullExceptionOnEncode, PixelTypes.Rgba32)]
18+
public void Encode_WithValidExifProfile_DoesNotThrowException<TPixel>(TestImageProvider<TPixel> provider)
19+
where TPixel : unmanaged, IPixel<TPixel>
20+
{
21+
Exception exception = Record.Exception(() =>
22+
{
23+
var encoder = new JpegEncoder();
24+
var stream = new MemoryStream();
25+
26+
using Image<TPixel> image = provider.GetImage(JpegDecoder);
27+
image.Save(stream, encoder);
28+
});
29+
30+
Assert.Null(exception);
31+
}
32+
}
33+
}

tests/ImageSharp.Tests/Formats/Jpg/JpegEncoderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace SixLabors.ImageSharp.Tests.Formats.Jpg
2121
{
2222
[Trait("Format", "Jpg")]
23-
public class JpegEncoderTests
23+
public partial class JpegEncoderTests
2424
{
2525
private static JpegEncoder JpegEncoder => new();
2626

tests/ImageSharp.Tests/TestImages.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public static class Issues
264264
public const string InvalidIptcTag = "Jpg/issues/Issue1942InvalidIptcTag.jpg";
265265
public const string Issue2057App1Parsing = "Jpg/issues/Issue2057-App1Parsing.jpg";
266266
public const string ExifNullArrayTag = "Jpg/issues/issue-2056-exif-null-array.jpg";
267+
public const string ValidExifArgumentNullExceptionOnEncode = "Jpg/issues/Issue2087-exif-null-reference-on-encode.jpg";
267268

268269
public static class Fuzz
269270
{
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)