Browse Source

cleanup, add empty profile writer test

pull/1923/head
Ildar Khayrutdinov 4 years ago
parent
commit
556c0a7c4f
  1. 5
      src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs
  2. 12
      tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs

5
src/ImageSharp/Metadata/Profiles/Exif/ExifWriter.cs

@ -50,11 +50,6 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
IExifValue exifOffset = GetOffsetValue(this.ifdValues, this.exifValues, ExifTag.SubIFDOffset);
IExifValue gpsOffset = GetOffsetValue(this.ifdValues, this.gpsValues, ExifTag.GPSIFDOffset);
if (this.ifdValues.Count == 0 && this.exifValues.Count == 0 && this.gpsValues.Count == 0)
{
return Array.Empty<byte>();
}
uint ifdLength = this.GetLength(this.ifdValues);
uint exifLength = this.GetLength(this.exifValues);
uint gpsLength = this.GetLength(this.gpsValues);

12
tests/ImageSharp.Tests/Metadata/Profiles/Exif/ExifProfileTests.cs

@ -87,6 +87,17 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Exif
new ExifProfile(Array.Empty<byte>());
}
[Fact]
public void EmptyWriter()
{
var profile = new ExifProfile() { Parts = ExifParts.GpsTags };
profile.SetValue(ExifTag.Copyright, "Copyright text");
byte[] bytes = profile.ToByteArray();
Assert.NotNull(bytes);
Assert.Empty(bytes);
}
[Fact]
public void ConstructorCopy()
{
@ -498,7 +509,6 @@ namespace SixLabors.ImageSharp.Tests.Metadata.Profiles.Exif
// Assert
int ifdOffset = ExifConstants.LittleEndianByteOrderMarker.Length;
Assert.Equal(8U, BinaryPrimitives.ReadUInt32LittleEndian(actualBytes.Slice(ifdOffset, 4)));
int nextIfdPointerOffset = ExifConstants.LittleEndianByteOrderMarker.Length + 4 + 2 + 12;

Loading…
Cancel
Save