From 98f18cbfeb542fd62338ca7670d39fc972c689dc Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Mon, 20 Feb 2017 07:14:23 +0100 Subject: [PATCH] Added extra test for trimming comments. --- .../Formats/Gif/GifEncoderCoreTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderCoreTests.cs b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderCoreTests.cs index 6f163bc6e..0e8e21780 100644 --- a/tests/ImageSharp.Tests/Formats/Gif/GifEncoderCoreTests.cs +++ b/tests/ImageSharp.Tests/Formats/Gif/GifEncoderCoreTests.cs @@ -63,5 +63,28 @@ namespace ImageSharp.Tests } } } + + [Fact] + public void Encode_CommentIsToLong_CommentIsTrimmed() + { + using (Image input = new Image(1, 1)) + { + string comments = new string('c', 256); + input.MetaData.Properties.Add(new ImageProperty("Comments", comments)); + + using (MemoryStream memStream = new MemoryStream()) + { + input.Save(memStream, new GifFormat()); + + memStream.Position = 0; + using (Image output = new Image(memStream)) + { + Assert.Equal(1, output.MetaData.Properties.Count); + Assert.Equal("Comments", output.MetaData.Properties[0].Name); + Assert.Equal(255, output.MetaData.Properties[0].Value.Length); + } + } + } + } } }