|
|
|
@ -1,8 +1,10 @@ |
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Copyright (c) Six Labors and contributors.
|
|
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Buffers; |
|
|
|
using System.Collections; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
@ -165,7 +167,7 @@ namespace SixLabors.ImageSharp.Tests.Memory.DiscontiguousBuffers |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Fill() |
|
|
|
public void FillWithFastEnumerator() |
|
|
|
{ |
|
|
|
using MemoryGroup<int> group = this.CreateTestGroup(100, 10, true); |
|
|
|
group.Fill(42); |
|
|
|
@ -177,6 +179,34 @@ namespace SixLabors.ImageSharp.Tests.Memory.DiscontiguousBuffers |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void FillWithSlowGenericEnumerator() |
|
|
|
{ |
|
|
|
using MemoryGroup<int> group = this.CreateTestGroup(100, 10, true); |
|
|
|
group.Fill(42); |
|
|
|
|
|
|
|
int[] expectedRow = Enumerable.Repeat(42, 10).ToArray(); |
|
|
|
IReadOnlyList<Memory<int>> groupAsList = group; |
|
|
|
foreach (Memory<int> memory in groupAsList) |
|
|
|
{ |
|
|
|
Assert.True(memory.Span.SequenceEqual(expectedRow)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void FillWithSlowEnumerator() |
|
|
|
{ |
|
|
|
using MemoryGroup<int> group = this.CreateTestGroup(100, 10, true); |
|
|
|
group.Fill(42); |
|
|
|
|
|
|
|
int[] expectedRow = Enumerable.Repeat(42, 10).ToArray(); |
|
|
|
IEnumerable groupAsList = group; |
|
|
|
foreach (Memory<int> memory in groupAsList) |
|
|
|
{ |
|
|
|
Assert.True(memory.Span.SequenceEqual(expectedRow)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Clear() |
|
|
|
{ |
|
|
|
|