From aa26b63e4b4e5619c5ec9847c01c8a96dc2a9d16 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 8 Aug 2021 18:33:54 +0200 Subject: [PATCH] Set_MaximumPoolSizeMegabytes_CreateImage_MaximumPoolSizeMegabytes --- .../Image/LargeImageIntegrationTests.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs index afa217bbc..240c9f568 100644 --- a/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs +++ b/tests/ImageSharp.Tests/Image/LargeImageIntegrationTests.cs @@ -2,6 +2,8 @@ // Licensed under the Apache License, Version 2.0. using System; +using Microsoft.DotNet.RemoteExecutor; +using SixLabors.ImageSharp.Memory; using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.Processing; using Xunit; @@ -19,10 +21,28 @@ namespace SixLabors.ImageSharp.Tests image.DebugSave(provider); } + [Fact] + public unsafe void Set_MaximumPoolSizeMegabytes_CreateImage_MaximumPoolSizeMegabytes() + { + RemoteExecutor.Invoke(RunTest).Dispose(); + + static void RunTest() + { + Configuration.Default.MemoryAllocator = MemoryAllocator.CreateDefault(new MemoryAllocatorOptions() + { + MinimumContiguousBlockBytes = sizeof(Rgba32) * 8192 * 4096 + }); + using Image image = new Image(8192, 4096); + Assert.True(image.TryGetSinglePixelSpan(out Span span)); + Assert.Equal(8192 * 4096, span.Length); + } + } + [Theory] [WithBasicTestPatternImages(width: 10, height: 10, PixelTypes.Rgba32)] - public void GetSingleSpan(TestImageProvider provider) + public void TryGetSinglePixelSpan_WhenImageTooLarge_ReturnsFalse(TestImageProvider provider) { + provider.LimitAllocatorBufferCapacity().InPixels(10); using Image image = provider.GetImage(); Assert.False(image.TryGetSinglePixelSpan(out Span imageSpan));