From 31e2a42cf16b4269d6b5ad3780ad4cc97f756a99 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 25 Jan 2018 13:45:17 +1100 Subject: [PATCH] Add simple clone test --- .../ImageSharp.Tests/Image/ImageCloneTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/ImageSharp.Tests/Image/ImageCloneTests.cs diff --git a/tests/ImageSharp.Tests/Image/ImageCloneTests.cs b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs new file mode 100644 index 0000000000..12e0fc8834 --- /dev/null +++ b/tests/ImageSharp.Tests/Image/ImageCloneTests.cs @@ -0,0 +1,36 @@ +using System; +using SixLabors.ImageSharp.Advanced; +using SixLabors.ImageSharp.PixelFormats; +using Xunit; + +namespace SixLabors.ImageSharp.Tests +{ + public class ImageCloneTests + { + [Theory] + [WithTestPatternImages(9, 9, PixelTypes.Rgba32)] + public void CloneAs_ToBgra32(TestImageProvider provider) + { + using (Image image = provider.GetImage()) + using (Image clone = image.CloneAs()) + { + for (int y = 0; y < image.Height; y++) + { + Span row = image.GetPixelRowSpan(y); + Span rowClone = clone.GetPixelRowSpan(y); + + for (int x = 0; x < image.Width; x++) + { + Rgba32 rgba = row[x]; + Bgra32 bgra = rowClone[x]; + + Assert.Equal(rgba.R, bgra.R); + Assert.Equal(rgba.G, bgra.G); + Assert.Equal(rgba.B, bgra.B); + Assert.Equal(rgba.A, bgra.A); + } + } + } + } + } +} \ No newline at end of file