Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Nov 17, 2017
1 parent 51350b5 commit 94e95c6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 135 deletions.
2 changes: 1 addition & 1 deletion tests/ImageSharp.Benchmarks/General/Block8x8F_Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void ScalarRound()
for (int i = 0; i < Block8x8F.Size; i++)
{
ref float v = ref Unsafe.Add(ref b, i);
v = MathF.Round(v);
v = (float)Math.Round(v);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/ImageSharp.Benchmarks/Samplers/Glow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected override void OnApply(ImageFrame<TPixel> source, Rectangle sourceRecta
int endX = sourceRectangle.Right;
TPixel glowColor = this.GlowColor;
Vector2 centre = Rectangle.Center(sourceRectangle);
float maxDistance = this.Radius > 0 ? MathF.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;
float maxDistance = this.Radius > 0 ? Math.Min(this.Radius, sourceRectangle.Width * .5F) : sourceRectangle.Width * .5F;

// Align start/end positions.
int minX = Math.Max(0, startX);
Expand Down Expand Up @@ -136,13 +136,13 @@ public static Vector4 PremultipliedLerp(Vector4 backdrop, Vector4 source, float
amount = amount.Clamp(0, 1);

// Santize on zero alpha
if (MathF.Abs(backdrop.W) < Constants.Epsilon)
if (Math.Abs(backdrop.W) < Constants.Epsilon)
{
source.W *= amount;
return source;
}

if (MathF.Abs(source.W) < Constants.Epsilon)
if (Math.Abs(source.W) < Constants.Epsilon)
{
return backdrop;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/ImageSharp.Tests/Common/SimdUtilsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public SimdUtilsTests(ITestOutputHelper output)
this.Output = output;
}

private static int R(float f) => (int)MathF.Round(f, MidpointRounding.AwayFromZero);
private static int R(float f) => (int)Math.Round(f, MidpointRounding.AwayFromZero);

private static int Re(float f) => (int)MathF.Round(f, MidpointRounding.ToEven);
private static int Re(float f) => (int)Math.Round(f, MidpointRounding.ToEven);

// TODO: Move this to a proper test class!
[Theory]
Expand Down Expand Up @@ -168,7 +168,7 @@ public void BulkConvertNormalizedFloatToByte_WithNonRoundedData(int seed, int co
Assert.Equal(expected, dest);
}

private static float Clamp255(float x) => MathF.Min(255f, MathF.Max(0f, x));
private static float Clamp255(float x) => Math.Min(255f, Math.Max(0f, x));

[Theory]
[InlineData(1, 0)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ImageSharp.Tests/Formats/Jpg/Block8x8FTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void RoundInplaceSlow(int seed)

for (int i = 0; i < 64; i++)
{
float expected = MathF.Round(s[i]);
float expected = (float)Math.Round(s[i]);
float actual = d[i];

Assert.Equal(expected, actual);
Expand Down
6 changes: 3 additions & 3 deletions tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ public void ConvertFromYcck(int inputBufferLength, int resultBufferLength, int s
float cr = values.Component2[i] - 128F;
float k = values.Component3[i] / 255F;

v.X = (255F - MathF.Round(y + (1.402F * cr), MidpointRounding.AwayFromZero)) * k;
v.Y = (255F - MathF.Round(
v.X = (255F - (float)Math.Round(y + (1.402F * cr), MidpointRounding.AwayFromZero)) * k;
v.Y = (255F - (float)Math.Round(
y - (0.344136F * cb) - (0.714136F * cr),
MidpointRounding.AwayFromZero)) * k;
v.Z = (255F - MathF.Round(y + (1.772F * cb), MidpointRounding.AwayFromZero)) * k;
v.Z = (255F - (float)Math.Round(y + (1.772F * cb), MidpointRounding.AwayFromZero)) * k;
v.W = 1F;

v *= scale;
Expand Down
123 changes: 0 additions & 123 deletions tests/ImageSharp.Tests/Helpers/MathFTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.

using System;

using SixLabors.ImageSharp.Helpers;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
Expand Down Expand Up @@ -245,7 +247,7 @@ public void ResizeWithMinMode<TPixel>(TestImageProvider<TPixel> provider)
{
var options = new ResizeOptions
{
Size = new Size((int)MathF.Round(image.Width * .75F), (int)MathF.Round(image.Height * .95F)),
Size = new Size((int)Math.Round(image.Width * .75F), (int)Math.Round(image.Height * .95F)),
Mode = ResizeMode.Min
};

Expand Down

0 comments on commit 94e95c6

Please sign in to comment.