mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using SixLabors.ImageSharp.Memory;
|
|
using Xunit;
|
|
|
|
namespace SixLabors.ImageSharp.Tests.Helpers
|
|
{
|
|
public class RowIntervalTests
|
|
{
|
|
[Theory]
|
|
[InlineData(10, 20, 5, 10)]
|
|
[InlineData(1, 10, 0, 10)]
|
|
[InlineData(1, 10, 5, 8)]
|
|
[InlineData(1, 1, 0, 1)]
|
|
[InlineData(10, 20, 9, 10)]
|
|
[InlineData(10, 20, 0, 1)]
|
|
public void GetMultiRowSpan(int width, int height, int min, int max)
|
|
{
|
|
using (Buffer2D<int> buffer = Configuration.Default.MemoryAllocator.Allocate2D<int>(width, height))
|
|
{
|
|
var rows = new RowInterval(min, max);
|
|
|
|
Span<int> span = buffer.GetMultiRowSpan(rows);
|
|
|
|
ref int expected0 = ref buffer.Span[min * width];
|
|
int expectedLength = (max - min) * width;
|
|
|
|
ref int actual0 = ref span[0];
|
|
|
|
Assert.Equal(span.Length, expectedLength);
|
|
Assert.True(Unsafe.AreSame(ref expected0, ref actual0));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|