From f600c33421012e506a767aacf5328d9d89501aa2 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 19 Apr 2018 14:37:17 -0700 Subject: [PATCH] Format SimdUtilsTests, part 2 --- .../ImageSharp.Tests/Common/SimdUtilsTests.cs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs index 503c7a283c..c6c3b68f33 100644 --- a/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs +++ b/tests/ImageSharp.Tests/Common/SimdUtilsTests.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using System; using System.Linq; using System.Numerics; using System.Runtime.CompilerServices; @@ -33,22 +36,10 @@ namespace SixLabors.ImageSharp.Tests.Common Vector4 actual = v.PseudoRound(); - Assert.Equal( - R(v.X), - (int)actual.X - ); - Assert.Equal( - R(v.Y), - (int)actual.Y - ); - Assert.Equal( - R(v.Z), - (int)actual.Z - ); - Assert.Equal( - R(v.W), - (int)actual.W - ); + Assert.Equal(R(v.X), (int)actual.X); + Assert.Equal(R(v.Y), (int)actual.Y); + Assert.Equal(R(v.Z), (int)actual.Z); + Assert.Equal(R(v.W), (int)actual.W); } private static Vector CreateExactTestVector1() @@ -70,12 +61,15 @@ namespace SixLabors.ImageSharp.Tests.Common private static Vector CreateRandomTestVector(int seed, float min, float max) { float[] data = new float[Vector.Count]; + var rnd = new Random(); + for (int i = 0; i < Vector.Count; i++) { float v = (float)rnd.NextDouble() * (max - min) + min; data[i] = v; } + return new Vector(data); } @@ -115,6 +109,7 @@ namespace SixLabors.ImageSharp.Tests.Common this.Output.WriteLine("Skipping AVX2 specific test case: " + testCaseName); return true; } + return false; } @@ -216,7 +211,7 @@ namespace SixLabors.ImageSharp.Tests.Common float[] source = { 0, 7, 42, 255, 0.5f, 1.1f, 2.6f, 16f }; - ReadOnlySpan expected = source.Select(f => (byte)Math.Round(f)).ToArray(); + var expected = source.Select(f => (byte)Math.Round(f)).ToArray(); source = source.Select(f => f / 255f).ToArray(); @@ -265,6 +260,7 @@ namespace SixLabors.ImageSharp.Tests.Common { int actual = (int)r[i]; int expected = Re(v[i]); + Assert.Equal(expected, actual); } }