Browse Source

move jpeg SpanExtensions into test utils

af/merge-core
Anton Firszov 9 years ago
parent
commit
abc62bbe7f
  1. 2
      tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegUtilityTestFixture.cs
  2. 40
      tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs
  3. 1
      tests/ImageSharp.Tests/ImageSharp.Tests.csproj

2
tests/ImageSharp.Tests/Formats/Jpg/Utils/JpegUtilityTestFixture.cs

@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
}
internal static float[] Create8x8RandomFloatData(int minValue, int maxValue, int seed = 42)
=> ImageSharp.Formats.Jpeg.GolangPort.Utils.SpanExtensions.ConvertAllToFloat(Create8x8RandomIntData(minValue, maxValue, seed));
=> SpanExtensions.ConvertAllToFloat(Create8x8RandomIntData(minValue, maxValue, seed));
internal void Print8x8Data<T>(T[] data) => this.Print8x8Data(new Span<T>(data));

40
src/ImageSharp/Formats/Jpeg/GolangPort/Utils/MutableSpanExtensions.cs → tests/ImageSharp.Tests/Formats/Jpg/Utils/SpanExtensions.cs

@ -1,12 +1,11 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
using System.Numerics;
using System.Runtime.CompilerServices;
namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils
namespace SixLabors.ImageSharp.Tests.Formats.Jpg.Utils
{
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
/// <summary>
/// Span Extensions
@ -85,22 +84,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils
return result;
}
/// <summary>
/// Converts all float values of src to int
/// </summary>
/// <param name="src">Source</param>
/// <returns>A new <see cref="Span{T}"/> with float values</returns>
public static Span<int> ConvertToInt32Span(this Span<float> src)
{
int[] result = new int[src.Length];
for (int i = 0; i < src.Length; i++)
{
result[i] = (int)src[i];
}
return result;
}
/// <summary>
/// Add a scalar to all values of src
/// </summary>
@ -134,22 +117,5 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Utils
return result;
}
/// <summary>
/// Copy all values in src to a new <see cref="Span{T}"/> instance
/// </summary>
/// <typeparam name="T">Element type</typeparam>
/// <param name="src">The source</param>
/// <returns>A new instance of <see cref="Span{T}"/></returns>
public static Span<T> Copy<T>(this Span<T> src)
{
T[] result = new T[src.Length];
for (int i = 0; i < src.Length; i++)
{
result[i] = src[i];
}
return result;
}
}
}

1
tests/ImageSharp.Tests/ImageSharp.Tests.csproj

@ -40,6 +40,5 @@
</ItemGroup>
<ItemGroup>
<Folder Include="TestUtilities\Factories\" />
<Folder Include="Utils\Jpg\Formats\" />
</ItemGroup>
</Project>
Loading…
Cancel
Save