From 595daff9cd4bd2e0851ce5044962acfd80686f94 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 13 Apr 2018 16:53:44 -0700 Subject: [PATCH] Add test to ensure the chunk type values are correct --- .../Formats/Png/PngChunkTests.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs diff --git a/tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs b/tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs new file mode 100644 index 000000000..3d1da000b --- /dev/null +++ b/tests/ImageSharp.Tests/Formats/Png/PngChunkTests.cs @@ -0,0 +1,29 @@ +using System; +using System.Buffers.Binary; +using System.Text; +using SixLabors.ImageSharp.Formats.Png; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Formats.Png +{ + public class PngChunkTests + { + [Fact] + public void ChunkTypeIdsAreCorrect() + { + Assert.Equal(PngChunkType.Header, GetType("IHDR")); + Assert.Equal(PngChunkType.Palette, GetType("PLTE")); + Assert.Equal(PngChunkType.Data, GetType("IDAT")); + Assert.Equal(PngChunkType.End, GetType("IEND")); + Assert.Equal(PngChunkType.PaletteAlpha, GetType("tRNS")); + Assert.Equal(PngChunkType.Text, GetType("tEXt")); + Assert.Equal(PngChunkType.Gamma, GetType("gAMA")); + Assert.Equal(PngChunkType.Physical, GetType("pHYs")); + } + + private static PngChunkType GetType(string text) + { + return (PngChunkType)BinaryPrimitives.ReadInt32BigEndian(Encoding.UTF8.GetBytes(text).AsSpan()); + } + } +}